diff options
| author | tv <tv@krebsco.de> | 2026-10-24 04:54:03 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 04:54:03 +0200 |
| commit | 409e53da1532872c60a21a70b124210850df4027 (patch) | |
| tree | 4be326d16c79a45219bb25a9105b030a32052c2c /src/state.rs | |
| parent | aa0e5167a231916a551296ea669222fd84629298 (diff) | |
prefer closer sources to catch up
Diffstat (limited to 'src/state.rs')
| -rw-r--r-- | src/state.rs | 6 |
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>> { |
