From 490234bbd44356da1cca0ad62b044e0cba70a226 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2026 06:09:22 +0200 Subject: add swarm stats --- src/swarm/stability.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/swarm/stability.rs') 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) { if let Some(away) = away { -- cgit v1.3.1