diff options
| author | tv <tv@krebsco.de> | 2026-10-30 15:10:29 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-30 15:10:29 +0100 |
| commit | 4250d9843133d38c7ace1a1b510265a15ebaa0fd (patch) | |
| tree | 3f996542020c3b44351a765fcf27119bc181f767 /src/state/timing.rs | |
| parent | 65d2118bcc9b7465c8086f2ca9c2b26c8ae7e57c (diff) | |
add dormant-probe-max option
Diffstat (limited to 'src/state/timing.rs')
| -rw-r--r-- | src/state/timing.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/state/timing.rs b/src/state/timing.rs index 9055ed6..988e430 100644 --- a/src/state/timing.rs +++ b/src/state/timing.rs @@ -11,8 +11,10 @@ const SYNC_REPLY_TIMEOUT: Duration = Duration::from_secs(10); /// tries to deliver a message (`Transport::delivery_limit`). const SYNC_REPLY_TIMEOUT_MAX_FACTOR: u32 = 30; /// Upper bound on the wait between probes of an unreachable peer, as a multiple of -/// `dormant_probe`: an hour at the default keepalive (1m). A returning node HELLOs its own -/// neighbours, so this only bounds how long one we never hear from stays out. +/// `dormant_probe`, unless `--dormant-probe-max` says otherwise: an hour at the default +/// keepalive (1m). A returning node HELLOs its own neighbours, and once one pair across +/// a partition meets, the rest are probed at once (`handshake::probe_now`), so this +/// bounds how long one we never hear from stays out. const PROBE_MAX_FACTOR: u32 = 6; #[derive(Clone, Copy, Debug)] @@ -25,6 +27,8 @@ pub(crate) struct Timing { pub(crate) dormant_after: Duration, pub(crate) resync_after: Duration, pub(crate) dormant_probe: Duration, + /// The longest wait between probes (`probe_backoff`). + pub(crate) probe_max: Duration, /// While catching up: send the source a STATUS after this much silence (`swarm::source`). pub(crate) catch_up_probe: Duration, /// First wait for an answer to a sync message before sending again; doubles while @@ -81,6 +85,7 @@ impl Timing { // the first sync reply timeout, so a lost message's sender resends it first. resync_after: (keepalive * 2).max(sync_reply_timeout * 2), dormant_probe: keepalive * 10, // >= 10*: dormant peers cost almost nothing, but still rejoin within minutes + probe_max: keepalive * 10 * PROBE_MAX_FACTOR, // Seconds, not a keepalive interval: a dead source should cost little time. // Only the source gets these, and only while catching up. catch_up_probe: (keepalive / 30).clamp(Duration::from_secs(1), Duration::from_secs(5)), @@ -89,10 +94,18 @@ impl Timing { } } + /// `--dormant-probe-max`, if given: the longest wait between probes. + pub(crate) fn with_probe_max(mut self, max: Option<Duration>) -> Self { + if let Some(max) = max { + self.probe_max = max; + } + self + } + /// Waits between probes of an unreachable peer: `dormant_probe`, doubling up to - /// `PROBE_MAX_FACTOR` times as much. + /// `probe_max` (all of them `probe_max` if that is shorter). pub(crate) fn probe_backoff(&self) -> Backoff { - Backoff::new(self.dormant_probe, self.dormant_probe * PROBE_MAX_FACTOR) + Backoff::new(self.dormant_probe.min(self.probe_max), self.probe_max) } /// Waits for sync answers: `sync_reply_timeout`, doubling up to 30 times as much. |
