use common::node_message::Payload; use common::node_types::BlockHash; use common::node_types::{Block, Timestamp}; use common::{id_type, time, DenseMap, MostSeen, NumStats}; use once_cell::sync::Lazy; use std::collections::HashSet; use std::str::FromStr; use std::time::{Duration, Instant}; use crate::feed_message::{self, ChainStats, FeedMessageSerializer}; use crate::find_location; use super::chain_stats::ChainStatsCollator; use super::counter::CounterValue; use super::node::Node; id_type! { /// A Node ID that is unique to the chain it's in. pub struct ChainNodeId(usize) } pub type Label = Box; const STALE_TIMEOUT: u64 = 2 * 60 * 1000; // 2 minutes const STATS_UPDATE_INTERVAL: Duration = Duration::from_secs(5); pub struct Chain { /// Labels that nodes use for this chain. We keep track of /// the most commonly used label as nodes are added/removed. labels: MostSeen