// Source code for the Substrate Telemetry Server. // Copyright (C) 2021 Parity Technologies (UK) Ltd. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . use common::node_message::Payload; use common::node_types::{Block, Timestamp}; use common::node_types::{BlockHash, BlockNumber}; use common::{id_type, time, DenseMap, MostSeen, NumStats}; use once_cell::sync::Lazy; use std::collections::HashSet; use crate::feed_message::{self, FeedMessageSerializer}; use crate::find_location; 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 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