From e92a712c1e1419c3d680396be827aa0a85748999 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 20:51:23 +0000 Subject: topology: neighbours among the members of a node's own party, and of parties named A node of a swarm holding a store keeps some of its neighbours among the members of its own party and of the parties its operator names (`--store-neighbour-parties`), so that a party listing many nodes can't be all of them (`docs/store.md`, Members): its neighbours by the shared graph among those members alone, each as its entry names it, which every node of its party computes alike, with those among all members. --- src/federation/held.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/federation') 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)>, pin: Option, party: Option, + /// The parties among whose members, with those of its own, the node keeps some of its + /// neighbours (`--store-neighbour-parties`). + near: Vec, /// 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>>, @@ -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) -> 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(&self, f: impl FnOnce(&Store) -> T) -> Option { self.inner.lock_or_recover().store.as_ref().map(f) -- cgit v1.3.1