From da94708e6df5c2a2c4b7fce3e67494a19122db9f Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Oct 2026 20:16:25 +0100 Subject: farewell means dormant --- src/state/peer.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/state/peer.rs') 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, -- cgit v1.3.1