hashiverse-server-lib 1.0.8

Hashiverse server library — production node implementation (HTTPS + ACME, Kademlia routing, DDoS protection, on-disk persistence) for your open-source decentralized X/Twitter replacement.
1
2
3
4
5
6
7
8
9
10
11
12
use crate::server::kademlia::kademlia::Kademlia;
use hashiverse_lib::protocol::peer::Peer;
use hashiverse_lib::tools::types::Id;

/// Build the `kademlia` subtree. v1 reports the total peer count across all
/// buckets — cheap (one walk of the bucket vector) and useful enough to spot
/// a node that has fallen off the DHT.
pub fn kademlia_stats_subtree(kademlia: &Kademlia<Id, Peer>) -> serde_json::Value {
    serde_json::json!({
        "peer_count": kademlia.len(),
    })
}