From e293047c25d7167f25af0a611b33545f12225b05 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 1 Nov 2026 20:36:17 +0100 Subject: peer worker sleeps until deadline, not fixed time --- src/swarm/source.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/swarm/source.rs') diff --git a/src/swarm/source.rs b/src/swarm/source.rs index e098dc1..1288d86 100644 --- a/src/swarm/source.rs +++ b/src/swarm/source.rs @@ -146,6 +146,7 @@ pub(crate) fn defer(state: &AppState, peer: &str, peer_state: &PeerState) -> Opt last_probe: None, refusals: 0, }); + state.peers_due.by(now + state.timing.catch_up_probe); None } @@ -285,6 +286,21 @@ pub(crate) fn probe_due(state: &AppState, peer: &str, now: Instant) -> bool { due } +/// When a STATUS to `peer` is next due (`probe_due`), if it is the source. +pub(crate) fn probe_at(state: &AppState, peer: &str) -> Option { + if !catching_up(state) { + return None; + } + let probe = state.timing.catch_up_probe; + let source = lock(state); + let current = source.as_ref().filter(|current| current.peer == peer)?; + let heard = current.last_heard + probe; + Some(match current.last_probe { + Some(last) => heard.max(last + probe), + None => heard, + }) +} + /// No catch-up going on: no source, no head start, nobody avoided. When one ends, and /// before one starts (a rejoin: `Host::reset_initial_sync`). pub(crate) fn reset(state: &AppState) { -- cgit v1.3.1