summaryrefslogtreecommitdiffstats
path: root/src/swarm/stability.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-24 06:09:22 +0200
committertv <tv@krebsco.de>2026-10-24 06:09:22 +0200
commit7542d33f5d476a35d068a4246399cc0c164dac06 (patch)
tree54290aafd8b3a11c85a01578dffdd0c7f9f8dd52 /src/swarm/stability.rs
parentecec63df16ba51fde6a63c9610a8296fa81c3f54 (diff)
add swarm stats
Diffstat (limited to 'src/swarm/stability.rs')
-rw-r--r--src/swarm/stability.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/swarm/stability.rs b/src/swarm/stability.rs
index 31ba4b8..9d79b17 100644
--- a/src/swarm/stability.rs
+++ b/src/swarm/stability.rs
@@ -135,6 +135,13 @@ fn lock(state: &AppState) -> std::sync::MutexGuard<'_, Stability> {
.unwrap_or_else(|poisoned| poisoned.into_inner())
}
+/// The fraction of the observed time (up to a day) we had a live peer, and how much
+/// time was observed.
+pub(crate) fn measured(state: &AppState) -> (f64, Duration) {
+ let stability = lock(state);
+ (stability.fraction(), stability.observed())
+}
+
/// A HELLO_REPLY told us how long ago that peer last heard from us before this run.
pub(crate) fn note_away(state: &AppState, away: Option<Duration>) {
if let Some(away) = away {