diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 59c6e9d4..12547a77 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1723,7 +1723,6 @@ name = "telemetry_core" version = "0.1.0" dependencies = [ "anyhow", - "arrayvec", "bimap", "bincode", "bytes", diff --git a/backend/common/src/node_types.rs b/backend/common/src/node_types.rs index 4f408138..efc7001f 100644 --- a/backend/common/src/node_types.rs +++ b/backend/common/src/node_types.rs @@ -38,7 +38,7 @@ pub struct NodeDetails { pub validator: Option>, pub network_id: NetworkId, pub startup_time: Option>, - pub target_os: Option>, //starts here + pub target_os: Option>, pub target_arch: Option>, pub target_env: Option>, pub sysinfo: Option, diff --git a/backend/telemetry_core/Cargo.toml b/backend/telemetry_core/Cargo.toml index 552e4d4a..79485dcf 100644 --- a/backend/telemetry_core/Cargo.toml +++ b/backend/telemetry_core/Cargo.toml @@ -21,7 +21,6 @@ maxminddb = "0.23.0" num_cpus = "1.13.0" once_cell = "1.8.0" parking_lot = "0.12.1" -arrayvec = { version = "0.7.1", features = ["serde"] } primitive-types = { version = "0.12.1", features = ["serde"] } rayon = "1.5.1" reqwest = { version = "0.11.4", features = ["json"] } diff --git a/backend/telemetry_core/src/feed_message.rs b/backend/telemetry_core/src/feed_message.rs index f4488eeb..017e59e2 100644 --- a/backend/telemetry_core/src/feed_message.rs +++ b/backend/telemetry_core/src/feed_message.rs @@ -17,9 +17,8 @@ //! This module provides a way of encoding the various messages that we'll //! send to subscribed feeds (browsers). -use std::collections::HashMap; -use arrayvec::ArrayString; + use serde::Serialize; use crate::state::Node; @@ -223,15 +222,12 @@ impl FeedMessageWrite for AddedNode<'_> { #[derive(Serialize)] pub struct ChainStatsUpdate<'a>(pub &'a ChainStats); -/// Ranking list out node details elements per node id and counts per elements -/// `list`: List of node detail element per its count [( item, count )] -/// `node_map`: A map + #[derive(Serialize, PartialEq, Eq, Default)] pub struct Ranking { pub list: Vec<(K, u64)>, pub other: u64, pub unknown: u64, - pub node_map: HashMap,K> } #[derive(Serialize, PartialEq, Eq, Default)] diff --git a/backend/telemetry_core/src/state/chain.rs b/backend/telemetry_core/src/state/chain.rs index 944a32b9..8e265a8b 100644 --- a/backend/telemetry_core/src/state/chain.rs +++ b/backend/telemetry_core/src/state/chain.rs @@ -227,9 +227,9 @@ impl Chain { } self.stats_collator - .update_hwbench(node.details(),old_hwbench.as_ref(), CounterValue::Decrement); + .update_hwbench(old_hwbench.as_ref(), CounterValue::Decrement); self.stats_collator - .update_hwbench(node.details(),node.hwbench(), CounterValue::Increment); + .update_hwbench(node.hwbench(), CounterValue::Increment); } _ => {} } diff --git a/backend/telemetry_core/src/state/chain_stats.rs b/backend/telemetry_core/src/state/chain_stats.rs index 1a57c09e..74df55ea 100644 --- a/backend/telemetry_core/src/state/chain_stats.rs +++ b/backend/telemetry_core/src/state/chain_stats.rs @@ -16,7 +16,6 @@ use super::counter::{Counter, CounterValue}; use crate::feed_message::ChainStats; -//use arrayvec::ArrayString; // These are the benchmark scores generated on our reference hardware. const REFERENCE_CPU_SCORE: u64 = 1028; const REFERENCE_MEMORY_SCORE: u64 = 14899; @@ -159,17 +158,16 @@ impl ChainStatsCollator { hwbench: Option<&common::node_types::NodeHwBench>, op: CounterValue, ) { - self.version.modify(details.network_id,Some(&*details.version), op); + self.version.modify(Some(&*details.version), op); self.target_os - .modify(details.network_id,details.target_os.as_ref().map(|value| &**value), op); + .modify(details.target_os.as_ref().map(|value| &**value), op); self.target_arch - .modify(details.network_id,details.target_arch.as_ref().map(|value| &**value), op); + .modify(details.target_arch.as_ref().map(|value| &**value), op); let sysinfo = details.sysinfo.as_ref(); self.cpu.modify( - details.network_id, sysinfo .and_then(|sysinfo| sysinfo.cpu.as_ref()) .map(|value| &**value), @@ -177,13 +175,12 @@ impl ChainStatsCollator { ); let memory = sysinfo.and_then(|sysinfo| sysinfo.memory.map(bucket_memory)); - self.memory.modify(details.network_id,memory.as_ref(), op); + self.memory.modify(memory.as_ref(), op); self.core_count - .modify(details.network_id,sysinfo.and_then(|sysinfo| sysinfo.core_count.as_ref()), op); + .modify(sysinfo.and_then(|sysinfo| sysinfo.core_count.as_ref()), op); self.linux_kernel.modify( - details.network_id, sysinfo .and_then(|sysinfo| sysinfo.linux_kernel.as_ref()) .map(kernel_version_number), @@ -191,7 +188,6 @@ impl ChainStatsCollator { ); self.linux_distro.modify( - details.network_id, sysinfo .and_then(|sysinfo| sysinfo.linux_distro.as_ref()) .map(|value| &**value), @@ -199,28 +195,24 @@ impl ChainStatsCollator { ); self.is_virtual_machine.modify( - details.network_id, sysinfo.and_then(|sysinfo| sysinfo.is_virtual_machine.as_ref()), op, ); self.cpu_vendor.modify( - details.network_id, sysinfo.and_then(|sysinfo| sysinfo.cpu.as_ref().map(cpu_vendor)), op, ); - self.update_hwbench(details,hwbench, op); + self.update_hwbench(hwbench, op); } pub fn update_hwbench( &mut self, - details: &common::node_types::NodeDetails, hwbench: Option<&common::node_types::NodeHwBench>, op: CounterValue, ) { self.cpu_hashrate_score.modify( - details.network_id, hwbench .map(|hwbench| bucket_score(hwbench.cpu_hashrate_score, REFERENCE_CPU_SCORE)) .as_ref(), @@ -228,7 +220,6 @@ impl ChainStatsCollator { ); self.memory_memcpy_score.modify( - details.network_id, hwbench .map(|hwbench| bucket_score(hwbench.memory_memcpy_score, REFERENCE_MEMORY_SCORE)) .as_ref(), @@ -236,7 +227,6 @@ impl ChainStatsCollator { ); self.disk_sequential_write_score.modify( - details.network_id, hwbench .and_then(|hwbench| hwbench.disk_sequential_write_score) .map(|score| bucket_score(score, REFERENCE_DISK_SEQUENTIAL_WRITE_SCORE)) @@ -245,7 +235,6 @@ impl ChainStatsCollator { ); self.disk_random_write_score.modify( - details.network_id, hwbench .and_then(|hwbench| hwbench.disk_random_write_score) .map(|score| bucket_score(score, REFERENCE_DISK_RANDOM_WRITE_SCORE)) diff --git a/backend/telemetry_core/src/state/counter.rs b/backend/telemetry_core/src/state/counter.rs index b8f5f946..b29e93ee 100644 --- a/backend/telemetry_core/src/state/counter.rs +++ b/backend/telemetry_core/src/state/counter.rs @@ -14,10 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use arrayvec::ArrayString; - use crate::feed_message::Ranking; -use std::{collections::HashMap, /*str::FromStr*/}; +use std::collections::HashMap; /// A data structure which counts how many occurrences of a given key we've seen. @@ -31,9 +29,6 @@ pub struct Counter { /// The number of occurrences where the key is `None`. empty: u64, - /// The map of Node Id ( Network Id) to the node detail element - /// i.e {"123DE": "aarch64"} - node_map: HashMap,K> } #[derive(Copy, Clone, PartialEq, Eq, Debug)] @@ -48,7 +43,7 @@ where { /// Either adds or removes a single occurence of a given `key`. - pub fn modify<'a, Q>(&mut self,node_id: ArrayString<64>, key: Option<&'a Q>, op: CounterValue) + pub fn modify<'a, Q>(&mut self, key: Option<&'a Q>, op: CounterValue) where Q: ?Sized + std::hash::Hash + Eq, K: std::borrow::Borrow, @@ -59,8 +54,6 @@ where match op { CounterValue::Increment => { *entry += 1; - // add the node Id and the value ( key ) to the node_map - self.node_map.insert(node_id, key.to_owned()); } CounterValue::Decrement => { @@ -69,20 +62,15 @@ where // Don't keep entries for which there are no hits. self.map.remove(key); } - // remove the node Id and the value ( key ) to the node_map - self.node_map.remove(&node_id); } } } else { assert_eq!(op, CounterValue::Increment); self.map.insert(key.to_owned(), 1); - // add the node Id and the value ( key ) to the node_map - self.node_map.insert(node_id, key.to_owned()); } } else { - // The key is None, no need to update the map (nodeId -> key) match op { CounterValue::Increment => { self.empty += 1; @@ -117,7 +105,6 @@ where list, other, unknown: self.empty, - node_map: self.node_map.clone(), } } @@ -133,7 +120,6 @@ where list, other: 0, unknown: self.empty, - node_map: self.node_map.clone(), } } } diff --git a/backend/telemetry_shard/src/json_message/mod.rs b/backend/telemetry_shard/src/json_message/mod.rs index 8e9ac852..2b54cf88 100644 --- a/backend/telemetry_shard/src/json_message/mod.rs +++ b/backend/telemetry_shard/src/json_message/mod.rs @@ -19,5 +19,4 @@ mod hash; mod node_message; -//pub use hash::Hash; pub use node_message::*; diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 750ec78e..96144827 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -72,7 +72,7 @@ export default class App extends React.Component { blockpropagation: true, blocklasttime: false, uptime: false, - version: true, //starts here + version: true, target_os: true, target_arch: true, core_count: true, diff --git a/frontend/src/Connection.ts b/frontend/src/Connection.ts index 54f58d1d..dc82061f 100644 --- a/frontend/src/Connection.ts +++ b/frontend/src/Connection.ts @@ -133,7 +133,7 @@ export class Connection { this.bindSocket(); } - public subscribe(chain: Types.GenesisHash) { //It has subscribed to the telemetry core + public subscribe(chain: Types.GenesisHash) { if ( this.appState.subscribed != null && this.appState.subscribed !== chain diff --git a/frontend/src/common/feed.ts b/frontend/src/common/feed.ts index f5f4909d..2ddc206b 100644 --- a/frontend/src/common/feed.ts +++ b/frontend/src/common/feed.ts @@ -99,7 +99,6 @@ interface AddedNodeMessage extends MessageBase { BlockDetails, Maybe, Maybe, - ]; } diff --git a/frontend/src/components/List/Row.css b/frontend/src/components/List/Row.css index 5204ff67..5f437534 100644 --- a/frontend/src/components/List/Row.css +++ b/frontend/src/components/List/Row.css @@ -44,5 +44,5 @@ along with this program. If not, see . } .Row:hover { - background-color: #1e1e1e; /*remember to change to #1e1e1e*/ + background-color: #1e1e1e; } diff --git a/frontend/src/components/List/Row.tsx b/frontend/src/components/List/Row.tsx index e6a482e2..09cded62 100644 --- a/frontend/src/components/List/Row.tsx +++ b/frontend/src/components/List/Row.tsx @@ -104,8 +104,6 @@ export class Row extends React.Component { public render() { const { node, columns } = this.props; - console.log('node details:',node ); - this.renderedChangeRef = node.changeRef; diff --git a/frontend/src/state.ts b/frontend/src/state.ts index 78da432f..6521bef8 100644 --- a/frontend/src/state.ts +++ b/frontend/src/state.ts @@ -291,8 +291,7 @@ export interface StateSettings { blockpropagation: boolean; blocklasttime: boolean; uptime: boolean; - - version: boolean; //starts here + version: boolean; target_os: boolean; target_arch: boolean; cpu: boolean;