From d6f6c2e020ac648b54c0e024596460ffb82ca437 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 6 Nov 2026 04:34:23 +0100 Subject: suspend detected --- src/swarm/stability.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/swarm/stability.rs') diff --git a/src/swarm/stability.rs b/src/swarm/stability.rs index 1ee308f..8163e06 100644 --- a/src/swarm/stability.rs +++ b/src/swarm/stability.rs @@ -148,6 +148,15 @@ pub(crate) fn note_away(state: &AppState, away: Option) { } } +/// The machine slept for `gap` (`swarm::suspend`): observed, and not connected. The +/// monotonic clock `record` goes by stopped meanwhile, so it doesn't see it. +pub(crate) fn away(state: &AppState, gap: Duration) { + let mut stability = lock(state); + if let Some(bucket) = stability.buckets.back_mut() { + bucket.observed += gap.min(WINDOW); + } +} + /// Measures, and updates our tier in the registry when it should change. Called every /// few seconds by the peer worker. pub(crate) async fn tick(state: &AppState) { -- cgit v1.3.1