aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/source.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 20:36:17 +0100
committertv <tv@krebsco.de>2026-11-01 20:36:17 +0100
commitdbb614e1ecf27ca37f54dba4e2c8fe3810af8c8c (patch)
treeac7c141812d534f3c51907e5634fcb6c8aadc468 /src/swarm/source.rs
parent7f018573730dc57f9608fe41faa54b44abba841d (diff)
peer worker sleeps until deadline, not fixed time
Diffstat (limited to 'src/swarm/source.rs')
-rw-r--r--src/swarm/source.rs16
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) {