aboutsummaryrefslogtreecommitdiffstats
path: root/src/config/mod.rs
diff options
context:
space:
mode:
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()),