mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-17 02:11:01 +00:00
Merge pull request #289 from paritytech/system-interval-decouple-values
Further decouple SystemInterval values.
This commit is contained in:
+20
-6
@@ -142,12 +142,26 @@ impl Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_stats(&mut self, interval: &SystemInterval) -> Option<&NodeStats> {
|
pub fn update_stats(&mut self, interval: &SystemInterval) -> Option<&NodeStats> {
|
||||||
if self.stats != interval.stats {
|
let mut changed = false;
|
||||||
self.stats = interval.stats;
|
|
||||||
Some(&self.stats)
|
if let Some(peers) = interval.peers {
|
||||||
} else {
|
if peers != self.stats.peers {
|
||||||
None
|
self.stats.peers = peers;
|
||||||
}
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(txcount) = interval.txcount {
|
||||||
|
if txcount != self.stats.txcount {
|
||||||
|
self.stats.txcount = txcount;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if changed {
|
||||||
|
Some(&self.stats)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_io(&mut self, interval: &SystemInterval) -> Option<&NodeIO> {
|
pub fn update_io(&mut self, interval: &SystemInterval) -> Option<&NodeIO> {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use actix::prelude::*;
|
|||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::de::IgnoredAny;
|
use serde::de::IgnoredAny;
|
||||||
use crate::node::{NodeDetails, NodeStats};
|
use crate::node::NodeDetails;
|
||||||
use crate::types::{Block, BlockNumber, BlockHash};
|
use crate::types::{Block, BlockNumber, BlockHash};
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Message)]
|
#[derive(Deserialize, Debug, Message)]
|
||||||
@@ -63,14 +63,14 @@ pub struct SystemConnected {
|
|||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct SystemInterval {
|
pub struct SystemInterval {
|
||||||
#[serde(flatten)]
|
pub peers: Option<u64>,
|
||||||
pub stats: NodeStats,
|
pub txcount: Option<u64>,
|
||||||
pub bandwidth_upload: Option<f64>,
|
pub bandwidth_upload: Option<f64>,
|
||||||
pub bandwidth_download: Option<f64>,
|
pub bandwidth_download: Option<f64>,
|
||||||
pub finalized_height: Option<BlockNumber>,
|
pub finalized_height: Option<BlockNumber>,
|
||||||
pub finalized_hash: Option<BlockHash>,
|
pub finalized_hash: Option<BlockHash>,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub block: Block,
|
pub block: Option<Block>,
|
||||||
pub network_state: Option<IgnoredAny>,
|
pub network_state: Option<IgnoredAny>,
|
||||||
pub used_state_cache_size: Option<f32>,
|
pub used_state_cache_size: Option<f32>,
|
||||||
}
|
}
|
||||||
@@ -132,9 +132,8 @@ impl Block {
|
|||||||
impl Details {
|
impl Details {
|
||||||
pub fn best_block(&self) -> Option<&Block> {
|
pub fn best_block(&self) -> Option<&Block> {
|
||||||
match self {
|
match self {
|
||||||
Details::BlockImport(block) | Details::SystemInterval(SystemInterval { block, .. }) => {
|
Details::BlockImport(block) => Some(block),
|
||||||
Some(block)
|
Details::SystemInterval(SystemInterval { block, .. }) => block.as_ref(),
|
||||||
}
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user