aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/stability.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm/stability.rs')
-rw-r--r--src/swarm/stability.rs9
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) {