From 5439b2e6b27a55a1da252cf745d0557686e9c815 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 04:16:59 +0000 Subject: remake: holding a store, a node follows an epoch only from a checkpoint it builds A node of a swarm holding a store rejoining an epoch (`docs/store.md`, Remakes) follows it only where its snapshot has the swarm's policy and store, and holds the node's document's checkpoint, one it builds from that document, or one its operator pinned; with an empty document, the root of its store too (`Holding::follows`). A made-up epoch holding another, the root after the store moved on, say, would leave it holding events whose history nobody puts again: it stays on its own, as when a rejoin's check fails, and tries again later. --- src/remake/catchup.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/remake/catchup.rs') 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(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 -- cgit v1.3.1