aboutsummaryrefslogtreecommitdiffstats
path: root/src/state
diff options
context:
space:
mode:
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,