From fb7e04544c798dcfa6a25f7db278427a9a39ddef Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2026 04:54:03 +0200 Subject: prefer closer sources to catch up --- src/state.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/state.rs') 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>>, + /// Since when a closer peer has had a head start to become the source. + pub(crate) catch_up_preference: Arc>>, } /// 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> { -- cgit v1.3.1