aboutsummaryrefslogtreecommitdiffstats
path: root/src/state
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-30 20:16:25 +0100
committertv <tv@krebsco.de>2026-10-30 20:16:25 +0100
commit183fc770f215d12489725bb8bf7990f311524af0 (patch)
treef1bbc319ba233571c5d135535e9b4f50e80d1fb1 /src/state
parent67ad4df2afb222a2c8b3582d850a015742dba391 (diff)
farewell means dormant
Diffstat (limited to 'src/state')
-rw-r--r--src/state/peer.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/state/peer.rs b/src/state/peer.rs
index 923c6d2..dc1b0ec 100644
--- a/src/state/peer.rs
+++ b/src/state/peer.rs
@@ -304,9 +304,23 @@ impl PeerState {
if self.liveness.is_dormant() || self.quiet_for(now) < timing.dormant_after {
return false;
}
+ self.incidents.dormancies += 1;
+ self.go_dormant(now);
+ true
+ }
+
+ /// The peer said farewell (it is shutting down): Dormant now, without waiting for
+ /// its silence, and not counted as an incident. Returns true on the transition.
+ pub(crate) fn say_farewell(&mut self, now: Instant) -> bool {
+ if self.liveness.is_dormant() {
+ return false;
+ }
+ self.go_dormant(now);
+ true
+ }
+ fn go_dormant(&mut self, now: Instant) {
self.liveness = Liveness::Dormant { since: now };
- self.incidents.dormancies += 1;
self.unreachable_since.get_or_insert(now);
self.reset_sync();
@@ -315,7 +329,6 @@ impl PeerState {
next_attempt: now + self.probe_backoff.next(),
};
}
- true
}
/// The keepalive an established, quiet peer needs, if any (and records it): a PING,