Skip to main content

hashiverse_server_lib/server/stats/
kademlia_stats.rs

1use crate::server::kademlia::kademlia::Kademlia;
2use hashiverse_lib::protocol::peer::Peer;
3use hashiverse_lib::tools::types::Id;
4
5/// Build the `kademlia` subtree. v1 reports the total peer count across all
6/// buckets — cheap (one walk of the bucket vector) and useful enough to spot
7/// a node that has fallen off the DHT.
8pub fn kademlia_stats_subtree(kademlia: &Kademlia<Id, Peer>) -> serde_json::Value {
9    serde_json::json!({
10        "peer_count": kademlia.len(),
11    })
12}