aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/topology/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-06 04:33:25 +0100
committertv <tv@krebsco.de>2026-11-06 04:33:25 +0100
commit26ff4ff86b58fed130ce6802ac4aceba8ee93443 (patch)
tree211d02471381b6a32a2362d1ecc43a51992ef6ae /src/swarm/topology/mod.rs
parent645ea5c150df5fd55493d91fd5d8ada614bd1252 (diff)
plan walks the neighbours
Diffstat (limited to 'src/swarm/topology/mod.rs')
-rw-r--r--src/swarm/topology/mod.rs11
1 files changed, 11 insertions, 0 deletions
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<String> {
+ 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),