client/network: Expose number of entries per Kademlia bucket (#7104)

Extend `sub_libp2p_kbuckets_num_nodes` Prometheus metric to expose the
number of nodes per bucket per Kademlia instance instead of only per
Kademlia instance.
This commit is contained in:
Max Inden
2020-09-15 11:34:22 +02:00
committed by GitHub
parent 9a547cbea6
commit 3d94d80309
4 changed files with 25 additions and 11 deletions
+6 -3
View File
@@ -211,9 +211,12 @@ impl<B: BlockT, H: ExHashT> Behaviour<B, H> {
self.discovery.add_known_address(peer_id, addr)
}
/// Returns the number of nodes that are in the Kademlia k-buckets.
pub fn num_kbuckets_entries(&mut self) -> impl ExactSizeIterator<Item = (&ProtocolId, usize)> {
self.discovery.num_kbuckets_entries()
/// Returns the number of nodes in each Kademlia kbucket for each Kademlia instance.
///
/// Identifies Kademlia instances by their [`ProtocolId`] and kbuckets by the base 2 logarithm
/// of their lower bound.
pub fn num_entries_per_kbucket(&mut self) -> impl ExactSizeIterator<Item = (&ProtocolId, Vec<(u32, usize)>)> {
self.discovery.num_entries_per_kbucket()
}
/// Returns the number of records in the Kademlia record stores.