From 26ff4ff86b58fed130ce6802ac4aceba8ee93443 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 6 Nov 2026 04:33:25 +0100 Subject: plan walks the neighbours --- src/swarm/topology/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/swarm/topology') diff --git a/src/swarm/topology/mod.rs b/src/swarm/topology/mod.rs index b001809..29e460f 100644 --- a/src/swarm/topology/mod.rs +++ b/src/swarm/topology/mod.rs @@ -195,6 +195,17 @@ pub(crate) fn is_listed(state: &AppState, peer: &str) -> bool { /// openings. Everyone is a neighbour until the view is known (while joining, or before /// any member registered), so joining works as in a full mesh. We always *answer* /// anyone who contacts us. +/// Our neighbours, as the view was last computed; none while it isn't known (when +/// everyone counts: `is_neighbour`). +pub(crate) fn our_neighbours(state: &AppState) -> Vec { + state + .neighbours + .read_or_recover() + .as_ref() + .map(|view| view.neighbours.iter().cloned().collect()) + .unwrap_or_default() +} + pub(crate) fn is_neighbour(state: &AppState, peer: &str) -> bool { match &*state.neighbours.read_or_recover() { Some(view) => view.neighbours.contains(peer), -- cgit v1.3.1