diff options
| author | tv <tv@krebsco.de> | 2026-11-06 04:33:25 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-06 04:33:25 +0100 |
| commit | 26ff4ff86b58fed130ce6802ac4aceba8ee93443 (patch) | |
| tree | 211d02471381b6a32a2362d1ecc43a51992ef6ae /src/swarm/topology | |
| parent | 645ea5c150df5fd55493d91fd5d8ada614bd1252 (diff) | |
plan walks the neighbours
Diffstat (limited to 'src/swarm/topology')
| -rw-r--r-- | src/swarm/topology/mod.rs | 11 |
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), |
