diff options
Diffstat (limited to 'src/remake')
| -rw-r--r-- | src/remake/catchup.rs | 16 | ||||
| -rw-r--r-- | src/remake/mod.rs | 5 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/remake/catchup.rs b/src/remake/catchup.rs index 4f98d7a..bb8b03b 100644 --- a/src/remake/catchup.rs +++ b/src/remake/catchup.rs @@ -393,12 +393,28 @@ async fn finish<H: Host>(host: &H) { let kept = host.rejoin_document().await; let own = host.remake().own_actors(); let now = host.now_millis(); + #[cfg(feature = "federation")] + let (holding, store) = (host.holding(), host.store_id()); let prepared = { let began = began.clone(); tokio::task::spawn_blocking(move || { let empty = Document::new(); let reference = kept.as_ref().or(old.as_ref()).unwrap_or(&empty); let prepared = prepare(©, reference, &began, previous, target, own, now); + // Holding a store, an epoch whose snapshot's checkpoint the node neither + // builds nor has pinned isn't followed. + #[cfg(feature = "federation")] + let prepared = match prepared { + Prepared::Ready { .. } => match snapshot::as_built(©, target) { + Ok(Some(snapshot)) => match holding.follows(&snapshot, reference, store) { + Ok(()) => prepared, + Err(why) => Prepared::Failed(why), + }, + Ok(None) => Prepared::Failed(format!("{target} has no snapshot")), + Err(why) => Prepared::Failed(why), + }, + other => other, + }; (prepared, old) }) .await diff --git a/src/remake/mod.rs b/src/remake/mod.rs index bd814da..1f7a644 100644 --- a/src/remake/mod.rs +++ b/src/remake/mod.rs @@ -217,6 +217,11 @@ pub(crate) trait Host: Clone + Send + Sync + 'static { #[cfg(feature = "federation")] fn holding(&self) -> Arc<crate::federation::held::Holding>; + /// The store this node's swarm holds, as its operator named it (`--store-id`, + /// `--store-root`), if any. + #[cfg(feature = "federation")] + fn store_id(&self) -> Option<crate::federation::store::Id>; + /// The epoch of the local replica. fn current_epoch(&self) -> Epoch; |
