aboutsummaryrefslogtreecommitdiffstats
path: root/src/config/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-30 14:55:03 +0000
committertv <tv@krebsco.de>2026-11-30 14:55:03 +0000
commit8017b0e69f0350c2a35629ae71d511ddf7a3aa9c (patch)
tree494d282a79985a19d2194717fa7a7e7a4bba52e1 /src/config/mod.rs
parent8e97bcfa65e92da21df912cc5e19cf18027b82b8 (diff)
A node of a swarm holding a store, on a set of events (--store-document)
With store-root or store-id, store-document names the file of the store's own document, a set of events: the node holds its store there and nothing in the Automerge document, syncs with nodes holding a set and no others, and goes on from the file when started again. Without a file yet it begins from the root (StoreStart::set); joining by the ID alone needs a file. What a checkpoint forgot is kept for store-keeps-forgotten (30 days). The file stands for store-file, and no checkpoint is pinned. The set is written to its file where it changed, every five seconds with the store's worker and as the node stops (Holding::save), what a checkpoint forgot longer ago let go of first. Simulations: a node behind catches up; a node goes on from its file.
Diffstat (limited to 'src/config/mod.rs')
-rw-r--r--src/config/mod.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index efc190d..9c82673 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -216,6 +216,22 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[
),
#[cfg(feature = "federation")]
option(
+ "store-document",
+ Kind::Text,
+ "PATH",
+ None,
+ "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. Can't be combined with store-file, which the file stands for, nor with store-checkpoint.",
+ ),
+ #[cfg(feature = "federation")]
+ option(
+ "store-keeps-forgotten",
+ Kind::Duration,
+ "DURATION",
+ Some("30d"),
+ "With store-document: for how long the node keeps what a checkpoint its store moved to forgot, for nodes still before that checkpoint, which build it from that. A node behind for longer starts from a checkpoint its operator pins.",
+ ),
+ #[cfg(feature = "federation")]
+ option(
"store-checkpoint",
Kind::Text,
"ID",
@@ -809,6 +825,14 @@ pub(crate) struct Settings {
#[cfg(feature = "federation")]
pub(crate) store_checkpoint: Option<String>,
#[cfg(feature = "federation")]
+ pub(crate) store_document: Option<PathBuf>,
+ #[cfg(feature = "federation")]
+ #[serde(
+ default = "default_store_keeps_forgotten",
+ with = "crate::units::duration_option"
+ )]
+ pub(crate) store_keeps_forgotten: Duration,
+ #[cfg(feature = "federation")]
pub(crate) store_party: Option<String>,
#[cfg(feature = "federation")]
#[serde(default)]
@@ -1070,6 +1094,10 @@ fn default_neighbours() -> usize {
fn default_electorate_window() -> Duration {
Duration::from_secs(7 * 24 * 3600)
}
+#[cfg(feature = "federation")]
+fn default_store_keeps_forgotten() -> Duration {
+ Duration::from_secs(30 * 24 * 3600)
+}
fn default_clock_skew_warn() -> Duration {
Duration::from_secs(2)
}
@@ -1332,6 +1360,7 @@ impl Settings {
let of_a_store = [
("store-file", self.store_file.is_some()),
("store-checkpoint", self.store_checkpoint.is_some()),
+ ("store-document", self.store_document.is_some()),
("store-party", self.store_party.is_some()),
("store-readers", !self.store_readers.is_empty()),
(
@@ -1355,6 +1384,16 @@ impl Settings {
return Ok(());
}
};
+ if self.store_document.is_some() {
+ if self.store_file.is_some() {
+ bail!("store-document holds what store-file would: unset store-file");
+ }
+ if self.store_checkpoint.is_some() {
+ bail!(
+ "store-document: a set of events starts from its root or from its file, from no pinned checkpoint: unset store-checkpoint"
+ );
+ }
+ }
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"
@@ -1482,6 +1521,8 @@ impl Settings {
#[cfg(feature = "federation")]
("store-checkpoint", self.store_checkpoint.is_some()),
#[cfg(feature = "federation")]
+ ("store-document", self.store_document.is_some()),
+ #[cfg(feature = "federation")]
("store-party", self.store_party.is_some()),
#[cfg(feature = "federation")]
("store-readers", !self.store_readers.is_empty()),