diff options
| author | tv <tv@krebsco.de> | 2026-11-01 20:36:17 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-01 20:36:17 +0100 |
| commit | e293047c25d7167f25af0a611b33545f12225b05 (patch) | |
| tree | 51d31d9538cc2b1d988dd1b4faa6a5cc65c33f05 /src/swarm/source.rs | |
| parent | 962fe4b43632822dc91fa6a4da6f6f295f4dba32 (diff) | |
peer worker sleeps until deadline, not fixed time
Diffstat (limited to 'src/swarm/source.rs')
| -rw-r--r-- | src/swarm/source.rs | 16 |
1 files changed, 16 insertions, 0 deletions
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<Instant> { + 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) { |
