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
commitda94708e6df5c2a2c4b7fce3e67494a19122db9f (patch)
treebfdaf79bc5c36d0bb19fd948b771a08cb91c141b /src/state
parent2e934b7404e8f8fc5b9308e72f275a7b91cb027a (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,