diff options
Diffstat (limited to 'src/swarm')
| -rw-r--r-- | src/swarm/rtt.rs | 11 | ||||
| -rw-r--r-- | src/swarm/throughput.rs | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/swarm/rtt.rs b/src/swarm/rtt.rs index 6dfe84a..60bcbc6 100644 --- a/src/swarm/rtt.rs +++ b/src/swarm/rtt.rs @@ -47,6 +47,17 @@ impl RttTable { self.from_hellos.retain(|peer, _| keep(peer)); } + /// How many peers it holds anything of. + #[cfg(test)] + pub(crate) fn len(&self) -> usize { + self.hellos + .keys() + .chain(self.from_paths.keys()) + .chain(self.from_hellos.keys()) + .collect::<std::collections::HashSet<_>>() + .len() + } + /// The paths layer's round-trip time to `peer` (`Transport::rtt`), as a PONG from /// it arrived. pub(crate) fn measured(&mut self, peer: &str, rtt: Duration, now: Instant) { diff --git a/src/swarm/throughput.rs b/src/swarm/throughput.rs index ec50693..c9bf7ee 100644 --- a/src/swarm/throughput.rs +++ b/src/swarm/throughput.rs @@ -130,6 +130,12 @@ impl ThroughputTable { pub(crate) fn retain(&mut self, mut keep: impl FnMut(&str) -> bool) { self.peers.retain(|peer, _| keep(peer)); } + + /// How many peers it holds an estimate of. + #[cfg(test)] + pub(crate) fn len(&self) -> usize { + self.peers.len() + } } #[cfg(test)] |
