aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/bootstrap.rs38
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 {