summaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-23 21:15:39 +0200
committertv <tv@krebsco.de>2026-10-23 21:15:39 +0200
commitf9731343f71beced8ec8c817d19022fdfebc4545 (patch)
tree2afef39befbfe4d04858f71996ab3c603485a1ed /src/state.rs
parentea53d62019b3905f6a1a8daeca06e5aeb5c3b6ad (diff)
catch up with a single source only
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/state.rs b/src/state.rs
index 3ee9c6c..4fbc05b 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -528,6 +528,17 @@ pub(crate) struct AppState {
/// While rejoining a newer epoch, the previous document, served read-only (and
/// marked stale) instead of answering 503.
pub(crate) stale: Arc<std::sync::RwLock<Option<StaleView>>>,
+
+ /// 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>>>,
+}
+
+/// The peer a catching-up node syncs with first (`swarm::sync::defer_for_catch_up`).
+#[derive(Clone, Debug)]
+pub(crate) struct CatchUpSource {
+ pub(crate) peer: String,
+ /// When it was chosen or last sent us something.
+ pub(crate) last_progress: Instant,
}
impl AppState {
@@ -986,6 +997,10 @@ impl Host for AppState {
fn reset_initial_sync(&self) {
self.initial_sync_done
.store(false, std::sync::atomic::Ordering::Release);
+ *self
+ .catch_up_source
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner()) = None;
}
fn subscribe_changes(&self) -> broadcast::Receiver<Arc<ChangeSet>> {