diff options
| author | tv <tv@krebsco.de> | 2026-12-01 01:58:17 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 01:58:17 +0000 |
| commit | eadf0952260ba4b21e791226cf5ad39e8f079c86 (patch) | |
| tree | cbe9c24f258942621e6983b2f3865e1eff042ef4 /src/swarm/bootstrap.rs | |
| parent | 34bfcb661ed74bf40809576bbb388362cb7ffaa1 (diff) | |
federation: a node on a set begins anew from another checkpoint its operator pins
A pin counted only while the node had no file of its set, so a node
behind for longer than the others keep what a checkpoint forgot, or one
undoing a move, had to start without its file, and lost what it refused
of its own and what its operator had it drop. The file now says which
checkpoint was pinned when the set began: with another pinned, and not
the one the store is at, the node gathers its set anew from that one,
its store refusing what the one in the file refused. A node of both
kinds makes its set of its document then, where it finds the pin.
Diffstat (limited to 'src/swarm/bootstrap.rs')
| -rw-r--r-- | src/swarm/bootstrap.rs | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/swarm/bootstrap.rs b/src/swarm/bootstrap.rs index 45c86e6..30eaf73 100644 --- a/src/swarm/bootstrap.rs +++ b/src/swarm/bootstrap.rs @@ -377,6 +377,27 @@ impl StoreStart { self.id ); } + // Another checkpoint pinned than the one the set began from, and not the + // one its store is at: the node begins anew from that one, keeping what + // it refused of its own and what its operator had it drop. + if let Some(pin) = pin + && set.pinned() != Some(pin) + { + if crate::federation::store::Id::of(set.store().checkpoint()) != pin { + // A node of both kinds finds it in its document, and makes its set + // of the store it reads there. + if both { + return Ok(None); + } + info!(swarm_id = %self.id, from = %pin, path = %path.display(), "Another checkpoint is pinned than the store's document began from: its set begins anew from what members give by that name"); + return Ok(Some(Begun::Start(Box::new( + Start::new(self.id, pin, keeps).refusing_as(&set), + )))); + } + let set = set.pinned_at(Some(pin)); + info!(swarm_id = %self.id, path = %path.display(), "Going on with the store's document"); + return Ok(Some(Begun::Set(Box::new(set)))); + } info!(swarm_id = %self.id, path = %path.display(), "Going on with the store's document"); return Ok(Some(Begun::Set(Box::new(set)))); } @@ -397,7 +418,7 @@ impl StoreStart { (_, pin) => { let at = pin.unwrap_or(self.id); info!(swarm_id = %self.id, from = %at, "Joining the swarm holding the store with nothing of it: its set begins from what members give by that name"); - Ok(Some(Begun::Start(Start::new(self.id, at, keeps)))) + Ok(Some(Begun::Start(Box::new(Start::new(self.id, at, keeps))))) } } } @@ -781,6 +802,21 @@ mod tests { let read = set_of(start, None).expect("from the file"); assert_eq!(read.store().taken(), &[Id::of(&write)]); } + // Another checkpoint pinned than the one the set began from: anew, from that + // one; a node of both kinds makes its set of its document then. The one its + // store is at: gone on with, and kept as pinned. + let another = Some(Id::of(b"a checkpoint")); + assert!(matches!( + store.set(&path, &files, another, keeps, false), + Ok(Some(Begun::Start(_))) + )); + assert!(matches!( + store.set(&path, &files, another, keeps, true), + Ok(None) + )); + let read = set_of(&store, Some(id)).expect("from the file"); + assert_eq!(read.store().taken(), &[Id::of(&write)]); + assert_eq!(read.pinned(), Some(id)); // Of another store, or no document: refused. let other_root = Spec::first(&[&Party::new("lass", 2)], &[]).root(); let other = StoreStart { |
