aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-06 06:02:19 +0100
committertv <tv@krebsco.de>2026-11-06 06:02:19 +0100
commitd9d398522a142283b537670068cc6418402d9546 (patch)
tree9253ee0761da39336296688f5c857786bcb9a665 /src/swarm
parent77ffa8807d0cf1f06bc040052f6a1873536a0255 (diff)
soak with churn test
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/rtt.rs11
-rw-r--r--src/swarm/throughput.rs6
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)]