mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-04-27 12:48:02 +00:00
Fix network ID and validator icons (#189)
* fix: Validator icons * fix: Propagation time for blocks < highest * fix: Reintroduce network_id to Rust backend
This commit is contained in:
@@ -204,7 +204,7 @@ impl Handler<UpdateNode> for Chain {
|
||||
let UpdateNode { nid, msg, raw } = msg;
|
||||
|
||||
if let Some(block) = msg.details.best_block() {
|
||||
let mut propagation_time = 0;
|
||||
let mut propagation_time = None;
|
||||
let now = now();
|
||||
|
||||
self.update_stale_nodes(now);
|
||||
@@ -224,7 +224,7 @@ impl Handler<UpdateNode> for Chain {
|
||||
self.serializer.push(feed::BestBlock(self.best.height, now, self.average_block_time));
|
||||
} else if block.height == self.best.height {
|
||||
if let Some(timestamp) = self.timestamp {
|
||||
propagation_time = now - timestamp;
|
||||
propagation_time = Some(now - timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,6 +257,10 @@ impl Handler<UpdateNode> for Chain {
|
||||
node.set_network_state(raw);
|
||||
}
|
||||
}
|
||||
Details::AfgAuthoritySet(authority) => {
|
||||
node.set_validator_address(authority.authority_id);
|
||||
return;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -55,7 +55,7 @@ impl Node {
|
||||
block: Block::zero(),
|
||||
block_timestamp: now(),
|
||||
block_time: 0,
|
||||
propagation_time: 0,
|
||||
propagation_time: None,
|
||||
},
|
||||
finalized: Block::zero(),
|
||||
throttle: 0,
|
||||
@@ -111,7 +111,7 @@ impl Node {
|
||||
&self.best
|
||||
}
|
||||
|
||||
pub fn update_block(&mut self, block: Block, timestamp: u64, propagation_time: u64) -> Option<&BlockDetails> {
|
||||
pub fn update_block(&mut self, block: Block, timestamp: u64, propagation_time: Option<u64>) -> Option<&BlockDetails> {
|
||||
if block.height > self.best.block.height {
|
||||
self.stale = false;
|
||||
self.best.block = block;
|
||||
@@ -182,6 +182,10 @@ impl Node {
|
||||
self.stale
|
||||
}
|
||||
|
||||
pub fn set_validator_address(&mut self, addr: Box<str>) {
|
||||
self.details.validator = Some(addr);
|
||||
}
|
||||
|
||||
pub fn set_network_state(&mut self, state: Bytes) {
|
||||
self.network_state = Some(state);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,9 @@ pub enum Details {
|
||||
#[serde(rename = "afg.received_commit")]
|
||||
AfgReceivedCommit(IgnoredAny),
|
||||
#[serde(rename = "afg.authority_set")]
|
||||
AfgAuthoritySet(IgnoredAny),
|
||||
AfgAuthoritySet(AfgAuthoritySet),
|
||||
#[serde(rename = "afg.finalized_blocks_up_to")]
|
||||
AfgFinalizedBlocksUpTo(IgnoredAny),
|
||||
#[serde(rename = "aura.pre_sealed_block")]
|
||||
AuraPreSealedBlock(IgnoredAny),
|
||||
#[serde(rename = "prepared_block_for_proposing")]
|
||||
@@ -81,6 +83,11 @@ pub struct Finalized {
|
||||
pub height: Box<str>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct AfgAuthoritySet {
|
||||
pub authority_id: Box<str>,
|
||||
}
|
||||
|
||||
impl Block {
|
||||
pub fn zero() -> Self {
|
||||
Block {
|
||||
|
||||
@@ -11,6 +11,8 @@ pub struct NodeDetails {
|
||||
pub name: Box<str>,
|
||||
pub implementation: Box<str>,
|
||||
pub version: Box<str>,
|
||||
pub validator: Option<Box<str>>,
|
||||
pub network_id: Option<Box<str>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@@ -31,7 +33,7 @@ pub struct BlockDetails {
|
||||
pub block: Block,
|
||||
pub block_time: u64,
|
||||
pub block_timestamp: u64,
|
||||
pub propagation_time: u64,
|
||||
pub propagation_time: Option<u64>,
|
||||
}
|
||||
|
||||
pub type NodeHardware<'a> = (&'a [f32], &'a [f32], &'a [f64], &'a [f64], &'a [f64]);
|
||||
@@ -52,8 +54,8 @@ impl Serialize for NodeDetails {
|
||||
tup.serialize_element(&self.name)?;
|
||||
tup.serialize_element(&self.implementation)?;
|
||||
tup.serialize_element(&self.version)?;
|
||||
tup.serialize_element::<Option<String>>(&None)?; // TODO Maybe<Address>
|
||||
tup.serialize_element::<Option<usize>>(&None)?; // TODO Maybe<NetworkId>
|
||||
tup.serialize_element(&self.validator)?; // TODO Maybe<Address>
|
||||
tup.serialize_element(&self.network_id)?; // TODO Maybe<NetworkId>
|
||||
tup.serialize_element("")?; // TODO Address
|
||||
tup.end()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user