aboutsummaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-30 17:57:55 +0000
committertv <tv@krebsco.de>2026-11-30 17:57:55 +0000
commit08ec65219991c7413c8cdef4ce77434f2a121331 (patch)
tree2c9d6f07e435a1ae37c62571579b170374cfbb70 /src/config
parent00e88cd983766abec32b5a14a8cbf20932a27f3c (diff)
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.
Diffstat (limited to 'src/config')
-rw-r--r--src/config/mod.rs21
1 files changed, 20 insertions, 1 deletions
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
@@ -224,6 +224,14 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[
),
#[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,
"DURATION",
@@ -827,6 +835,9 @@ pub(crate) struct Settings {
#[cfg(feature = "federation")]
pub(crate) store_document: Option<PathBuf>,
#[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()),