diff options
| author | tv <tv@krebsco.de> | 2026-11-06 04:34:23 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-06 04:34:23 +0100 |
| commit | d6f6c2e020ac648b54c0e024596460ffb82ca437 (patch) | |
| tree | d2b35b071b8f2f878ab333bf39d169c14015d7d1 /src/swarm/stability.rs | |
| parent | b4d0f3d9671c3bac8fd3c4b6c3f5f75196a06742 (diff) | |
suspend detected
Diffstat (limited to 'src/swarm/stability.rs')
| -rw-r--r-- | src/swarm/stability.rs | 9 |
1 files changed, 9 insertions, 0 deletions
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<Duration>) { } } +/// 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) { |
