From 371e52cb48bae99232547f6fae6a0487a85c2d04 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2026 16:18:58 +0200 Subject: add chunked download and use it during rejoin --- src/remake/local.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/remake/local.rs') diff --git a/src/remake/local.rs b/src/remake/local.rs index d2ea2c2..787bd5e 100644 --- a/src/remake/local.rs +++ b/src/remake/local.rs @@ -34,6 +34,8 @@ struct Inner { catch_up: Option, /// A rejoin in progress: the node syncs an empty document of a newer epoch. rejoin: Option, + /// While the rejoin downloads the target epoch's snapshot (`catchup`), sync waits. + fetching_snapshot: Option, quarantine: Vec, } @@ -211,6 +213,23 @@ impl RemakeState { self.lock().rejoin.take() } + /// Whether sync should wait: a rejoin is downloading its epoch's snapshot. + pub(crate) fn fetching_snapshot(&self) -> bool { + self.lock().fetching_snapshot.is_some() + } + + pub(crate) fn set_fetching_snapshot(&self, target: Option) { + self.lock().fetching_snapshot = target; + } + + /// The rejoin of `target`, if still in progress, gets its full time for the sync + /// that follows the download. + pub(crate) fn restart_rejoin_clock(&self, target: Epoch) { + if let Some(rejoin) = self.lock().rejoin.as_mut().filter(|r| r.target == target) { + rejoin.started = Instant::now(); + } + } + pub(crate) fn add_quarantine(&self, quarantined: Quarantined) { self.lock().quarantine.push(quarantined); } -- cgit v1.3.1