diff options
Diffstat (limited to 'src/swarm/topology/mod.rs')
| -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), |
