summaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-24 04:54:03 +0200
committertv <tv@krebsco.de>2026-10-24 04:54:49 +0200
commitfb7e04544c798dcfa6a25f7db278427a9a39ddef (patch)
tree99fbb2557d18965919f824e3895ae974f1bd5f39 /src/state.rs
parent6b046a5c18d670c3097b8563c191a2dc06ce1179 (diff)
prefer closer sources to catch up
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/state.rs b/src/state.rs
index 2bc9264..6021baa 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -549,6 +549,8 @@ pub(crate) struct AppState {
/// While the initial sync isn't done: the one peer we catch up from.
pub(crate) catch_up_source: Arc<std::sync::Mutex<Option<CatchUpSource>>>,
+ /// Since when a closer peer has had a head start to become the source.
+ pub(crate) catch_up_preference: Arc<std::sync::Mutex<Option<Instant>>>,
}
/// The peer a catching-up node syncs with first (`swarm::source`).
@@ -1029,6 +1031,10 @@ impl Host for AppState {
.catch_up_source
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner()) = None;
+ *self
+ .catch_up_preference
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner()) = None;
}
fn subscribe_changes(&self) -> broadcast::Receiver<Arc<ChangeSet>> {