aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation
diff options
context:
space:
mode:
Diffstat (limited to 'src/federation')
-rw-r--r--src/federation/held.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/federation/held.rs b/src/federation/held.rs
index fe8b6a9..542aeed 100644
--- a/src/federation/held.rs
+++ b/src/federation/held.rs
@@ -84,6 +84,9 @@ pub(crate) struct Holding {
file: Option<(PathBuf, Arc<Files>)>,
pin: Option<Id>,
party: Option<String>,
+ /// The parties among whose members, with those of its own, the node keeps some of its
+ /// neighbours (`--store-neighbour-parties`).
+ near: Vec<String>,
/// The members the store names, each with its party, as it reads now: apart from the
/// store, so that whoever asks doesn't wait while the store takes events.
members: RwLock<Option<BTreeSet<(String, String)>>>,
@@ -151,6 +154,7 @@ impl Holding {
file: Some((path, files)),
pin,
party,
+ near: Vec::new(),
members: RwLock::default(),
inner: Mutex::new(Inner {
kept,
@@ -352,6 +356,25 @@ impl Holding {
self.party.as_deref()
}
+ /// Itself, the node keeping some of its neighbours among the members of `parties`,
+ /// with those of its own (`--store-neighbour-parties`).
+ pub(crate) fn near(self, parties: Vec<String>) -> Self {
+ Holding {
+ near: parties,
+ ..self
+ }
+ }
+
+ /// The parties among whose members, with those of its own, the node keeps some of its
+ /// neighbours: its own first.
+ pub(crate) fn nearby(&self) -> Vec<&str> {
+ self.party
+ .iter()
+ .chain(&self.near)
+ .map(String::as_str)
+ .collect()
+ }
+
/// `f` of the store, where the node holds one.
pub(crate) fn with<T>(&self, f: impl FnOnce(&Store<Federation>) -> T) -> Option<T> {
self.inner.lock_or_recover().store.as_ref().map(f)