diff options
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/mod.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 726ca12..762e9a4 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -240,6 +240,14 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ None, "With store-root or store-id, which need it: the party this node is of (docs/store.md, Members), named in its entry and its handshakes. Nodes of a swarm holding a store sync with the nodes its parties list, each as its party's, and with no others.", ), + #[cfg(feature = "federation")] + option( + "store-neighbour-parties", + Kind::List, + "NAME,[NAME...]", + None, + "With store-root or store-id: parties among whose members, with those of its own party, this node keeps some of its neighbours, by the graph among those alone (docs/store.md, Members): so that a party listing many nodes can't be all of them.", + ), option( "strict-keys", Kind::List, @@ -681,6 +689,9 @@ pub(crate) struct Settings { pub(crate) store_checkpoint: Option<String>, #[cfg(feature = "federation")] pub(crate) store_party: Option<String>, + #[cfg(feature = "federation")] + #[serde(default)] + pub(crate) store_neighbour_parties: Vec<String>, #[serde(default)] pub(crate) strict_keys: Vec<String>, @@ -1156,6 +1167,10 @@ impl Settings { ("store-file", self.store_file.is_some()), ("store-checkpoint", self.store_checkpoint.is_some()), ("store-party", self.store_party.is_some()), + ( + "store-neighbour-parties", + !self.store_neighbour_parties.is_empty(), + ), ]; let set: Vec<&str> = of_a_store .iter() @@ -1181,6 +1196,13 @@ impl Settings { ), Some(_) => {} } + if let Some(party) = self + .store_neighbour_parties + .iter() + .find(|party| !crate::federation::version::is_party(party)) + { + bail!("store-neighbour-parties: {party:?} isn't a party's name"); + } let first_change = [ ("genesis", self.genesis), ("bootstrap-users", !self.bootstrap_users.is_empty()), @@ -1255,6 +1277,11 @@ impl Settings { ("store-checkpoint", self.store_checkpoint.is_some()), #[cfg(feature = "federation")] ("store-party", self.store_party.is_some()), + #[cfg(feature = "federation")] + ( + "store-neighbour-parties", + !self.store_neighbour_parties.is_empty(), + ), ("alias", self.alias.is_some()), ("dashboard-url", self.dashboard_url.is_some()), ("debug-api", self.debug_api), @@ -2351,6 +2378,19 @@ mod tests { assert!(checked(json!({ "store-party": "tv" })).is_err()); assert!(checked(json!({ "store-file": "store.json" })).is_err()); assert!( + checked( + json!({ "store-id": id, "store-party": "tv", "store-neighbour-parties": ["lass"] }) + ) + .is_ok() + ); + assert!( + checked( + json!({ "store-id": id, "store-party": "tv", "store-neighbour-parties": ["l s"] }) + ) + .is_err() + ); + assert!(checked(json!({ "store-neighbour-parties": ["lass"] })).is_err()); + assert!( checked(json!({ "store-id": id, "store-root": "root.json", "store-party": "tv" })) .is_err() ); |
