aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/topology/mod.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/swarm/topology/mod.rs b/src/swarm/topology/mod.rs
index 1d42724..f2538cc 100644
--- a/src/swarm/topology/mod.rs
+++ b/src/swarm/topology/mod.rs
@@ -399,6 +399,39 @@ fn of_the_store(
.collect()
}
+/// In a swarm holding a store, this node's neighbours among the members of its own party
+/// and of those its operator names (`Holding::nearby`), each as its entry names it, by the
+/// shared graph among those alone, as each of them computes it (`docs/store.md`,
+/// Members): so that a party listing many nodes can't be all of them.
+#[cfg(feature = "federation")]
+async fn nearby(state: &AppState, inputs: &Inputs<'_>) -> BTreeSet<String> {
+ let parties = state.holding.nearby();
+ if parties.is_empty() || !state.holding.tells_members() {
+ return BTreeSet::new();
+ }
+ let group: BTreeMap<String, BTreeSet<String>> = {
+ let replica = state.doc.read().await;
+ inputs
+ .transports
+ .iter()
+ .filter(|(member, _)| {
+ members::party(&replica.doc, member)
+ .is_some_and(|party| parties.contains(&party.as_str()))
+ })
+ .map(|(member, transports)| (member.clone(), transports.clone()))
+ .collect()
+ };
+ neighbours_across(
+ &RingAndPairs,
+ &group,
+ state.local_id(),
+ inputs.local_transports,
+ inputs.k,
+ inputs.unreachable,
+ inputs.stable,
+ )
+}
+
/// Whether `peer` is in the member list, as the view was last computed from it; None
/// while the view isn't known.
pub(crate) fn listed(state: &AppState, peer: &str) -> Option<bool> {
@@ -863,6 +896,8 @@ pub(crate) async fn refresh(state: &AppState) -> Option<NeighbourChange> {
None => state.peer_states.read().await.keys().cloned().collect(),
};
let mut computed = topology.neighbours(state.local_id(), &inputs);
+ #[cfg(feature = "federation")]
+ computed.extend(nearby(state, &inputs).await);
computed.extend(outbound.iter().cloned());
#[cfg(test)]
let listed_neighbours = computed.len();