From b88be3ea1b475b1a656298b98708026388eaf2af Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Oct 2026 02:54:55 +0100 Subject: move keepalive and firewall to paths --- src/state/timing.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/state/timing.rs') diff --git a/src/state/timing.rs b/src/state/timing.rs index 6ce5bef..9055ed6 100644 --- a/src/state/timing.rs +++ b/src/state/timing.rs @@ -18,6 +18,10 @@ const PROBE_MAX_FACTOR: u32 = 6; #[derive(Clone, Copy, Debug)] pub(crate) struct Timing { pub(crate) keepalive: Duration, + /// How often a quiet pair's keepalive is a STATUS rather than a PING + /// (`PeerState::take_keepalive_due`): its state (heads, readiness, epoch) for the heal + /// and against lost announcements. Changes go out as they happen anyway. + pub(crate) status_refresh: Duration, pub(crate) dormant_after: Duration, pub(crate) resync_after: Duration, pub(crate) dormant_probe: Duration, @@ -43,8 +47,9 @@ impl Timing { /// /// Each node keeps about `k` neighbours (`--neighbours`) whatever the swarm's size, /// and only one side of a pair sends them, so idle, a node sends about `k` messages and - /// receives about `k` (STATUSes and STATUS_REPLYs) per keepalive interval (more on a stable - /// member others prefer). The interval trades that against how soon a silent peer is + /// receives about `k` per keepalive interval (more on a stable member others prefer): + /// PINGs and PONGs (a few bytes), every third a STATUS and STATUS_REPLY (heads, + /// readiness, epoch) instead. The interval trades that against how soon a silent peer is /// noticed (`dormant_after`, 4 intervals) and a gap closes (within an interval). /// Recommended: /// @@ -68,7 +73,10 @@ impl Timing { ) -> Self { Self { keepalive, - dormant_after: keepalive * 4, // dormant_after >= 4* keepalive to tolerate three lost STATUSes in a row + // Every third keepalive; with `resync_after` at two keepalives, a heal needs + // two STATUSes that differ: within about two refreshes. + status_refresh: keepalive * 3, + dormant_after: keepalive * 4, // dormant_after >= 4* keepalive to tolerate three lost keepalives in a row // >= 2 keepalives, so a second exchange confirms the difference; and >= twice // the first sync reply timeout, so a lost message's sender resends it first. resync_after: (keepalive * 2).max(sync_reply_timeout * 2), -- cgit v1.3.1