From 08ec65219991c7413c8cdef4ce77434f2a121331 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 30 Nov 2026 17:57:55 +0000 Subject: A node of both kinds, for a swarm to move to sets by (--store-both) With store-document, store-both has the node hold its store in the Automerge document too, and sync with nodes of either kind: * it says to each peer the kind that peer holds, and passes its set on to those that hold sets (swarm::set::holds_a_set), the Automerge document to the others; * what its set takes of the document goes on to the peers on sets (Holding::unpassed), and what its set takes of them is put into the document, as events it lacks are (Holding::lacking); * its entry in the document is put as its entry in the set (swarm::set::mirror_entry), and it reads the members of both; * without the set's file yet, its set is made of the store as it reads it of its document, with what store-file kept of its own. A simulation: two nodes on the Automerge document, one on a set, one of both between them; an event put on either side reaches all four. --- src/config/mod.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/config/mod.rs') diff --git a/src/config/mod.rs b/src/config/mod.rs index 5a723c7..7b17f5d 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -223,6 +223,14 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ "With store-root or store-id: hold the store in a document of its own kind, a set of events (docs/document.md), kept in this file, instead of in the Automerge document a swarm syncs otherwise. The node then syncs with nodes holding such a set, and with no others: a swarm is of one kind. The file holds the store's events, what the node refused of its own and what its operator had it drop, and its members' entries; started again, the node goes on from it. Without the file yet, the node begins it from the root where it is given one (store-root) and pins no checkpoint; else it joins with nothing, and gathers of the members it reaches what its set begins from, by name: the root, or the checkpoint store-checkpoint names. Can't be combined with store-file, which the file stands for.", ), #[cfg(feature = "federation")] + option( + "store-both", + Kind::Flag, + "BOOL", + Some("false"), + "With store-document: hold the store in the Automerge document too, and sync with nodes of either kind, taking into each what the other holds: an event that comes by one goes on by the other, and the node's entry is in both. For moving a running swarm to sets of events node by node (docs/document.md, From an Automerge document to this): a node is started with it, on the document it has, and without it once no node it reaches holds the Automerge document alone. Without the set's file yet, the set begins from the store as the node reads it of its document.", + ), + #[cfg(feature = "federation")] option( "store-keeps-forgotten", Kind::Duration, @@ -827,6 +835,9 @@ pub(crate) struct Settings { #[cfg(feature = "federation")] pub(crate) store_document: Option, #[cfg(feature = "federation")] + #[serde(default)] + pub(crate) store_both: bool, + #[cfg(feature = "federation")] #[serde( default = "default_store_keeps_forgotten", with = "crate::units::duration_option" @@ -1361,6 +1372,7 @@ impl Settings { ("store-file", self.store_file.is_some()), ("store-checkpoint", self.store_checkpoint.is_some()), ("store-document", self.store_document.is_some()), + ("store-both", self.store_both), ("store-party", self.store_party.is_some()), ("store-readers", !self.store_readers.is_empty()), ( @@ -1384,9 +1396,14 @@ impl Settings { return Ok(()); } }; - if self.store_document.is_some() && self.store_file.is_some() { + if self.store_document.is_some() && self.store_file.is_some() && !self.store_both { bail!("store-document holds what store-file would: unset store-file"); } + if self.store_both && self.store_document.is_none() { + bail!( + "store-both: set store-document, the file of the set of events the node holds beside its Automerge document" + ); + } match &self.store_party { None => bail!( "{store}: set store-party, the party this node is of: in a swarm holding a store, nodes sync with the nodes its parties list, each as its party's" @@ -1516,6 +1533,8 @@ impl Settings { #[cfg(feature = "federation")] ("store-document", self.store_document.is_some()), #[cfg(feature = "federation")] + ("store-both", self.store_both), + #[cfg(feature = "federation")] ("store-party", self.store_party.is_some()), #[cfg(feature = "federation")] ("store-readers", !self.store_readers.is_empty()), -- cgit v1.3.1