Further reduce the CPU overhead of networking metrics (#10875)

* Simplify `num_connected_peers`

* Track requested peer counts

* Revert "Track requested peer counts"

This reverts commit 9f1c8704353df6afc17ed7e9f4ab8d8e29466ae4.

* Remove `substrate_sub_libp2p_peerset_num_requested` metric

* Remove two unused functions that I forgot to get rid of in previous commit
This commit is contained in:
Koute
2022-02-18 21:35:43 +09:00
committed by GitHub
parent 2777d4a154
commit b9a20ce86b
4 changed files with 1 additions and 37 deletions
@@ -251,16 +251,6 @@ impl PeerState {
_ => None,
}
}
/// True if that node has been requested by the PSM.
fn is_requested(&self) -> bool {
matches!(
self,
Self::PendingRequest { .. } |
Self::Requested | Self::DisabledPendingEnable { .. } |
Self::Enabled { .. }
)
}
}
/// State of the handler of a single connection visible from this state machine.
@@ -560,17 +550,6 @@ impl Notifications {
}
}
/// Returns the list of all the peers that the peerset currently requests us to be connected to.
pub fn requested_peers<'a>(
&'a self,
set_id: sc_peerset::SetId,
) -> impl Iterator<Item = &'a PeerId> + 'a {
self.peers
.iter()
.filter(move |((_, set), state)| *set == set_id && state.is_requested())
.map(|((id, _), _)| id)
}
/// Returns the list of reserved peers.
pub fn reserved_peers<'a>(
&'a self,