summaryrefslogtreecommitdiffstats
path: root/src/state/timing.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-28 02:54:55 +0100
committertv <tv@krebsco.de>2026-10-28 02:54:55 +0100
commitb88be3ea1b475b1a656298b98708026388eaf2af (patch)
tree9ffb3c42800c348ae4d67d1d9a43daa608c2269d /src/state/timing.rs
parent24327be7e09c20a9820eac61ba3ac60fb7bdb424 (diff)
move keepalive and firewall to paths
Diffstat (limited to 'src/state/timing.rs')
-rw-r--r--src/state/timing.rs14
1 files changed, 11 insertions, 3 deletions
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),