diff options
Diffstat (limited to 'src/state.rs')
| -rw-r--r-- | src/state.rs | 15 |
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>> { |
