diff options
| author | tv <tv@krebsco.de> | 2026-10-24 06:09:22 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 06:09:22 +0200 |
| commit | 490234bbd44356da1cca0ad62b044e0cba70a226 (patch) | |
| tree | 74c1b840a125bc9317602c63e29cbf8f81853b3d /src/swarm/stability.rs | |
| parent | e0ab17f665bb476329e0c7f980f31bb10cbfc944 (diff) | |
add swarm stats
Diffstat (limited to 'src/swarm/stability.rs')
| -rw-r--r-- | src/swarm/stability.rs | 7 |
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 { |
