aboutsummaryrefslogtreecommitdiffstats
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
parent645ea5c150df5fd55493d91fd5d8ada614bd1252 (diff)
plan walks the neighbours
-rw-r--r--src/swarm/topology/mod.rs11
-rw-r--r--src/swarm/tree.rs9
2 files changed, 16 insertions, 4 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),
diff --git a/src/swarm/tree.rs b/src/swarm/tree.rs
index 3ed8a9b..9c9651e 100644
--- a/src/swarm/tree.rs
+++ b/src/swarm/tree.rs
@@ -586,10 +586,11 @@ pub(crate) async fn plan(state: &AppState, writer: u64) -> Option<Plan> {
}
}
// Neighbours the member list's graph doesn't give us (not listed yet, or only
- // connecting out): no tree has them.
- for (peer, _) in state.peers_snapshot().await {
- if topology::is_neighbour(state, &peer)
- && !graph.get(me).is_some_and(|ours| ours.contains(&peer))
+ // connecting out): no tree has them. From the neighbours, not every peer known: this
+ // runs for every change passed on.
+ for peer in topology::our_neighbours(state) {
+ if !graph.get(me).is_some_and(|ours| ours.contains(&peer))
+ && state.get_peer_state(&peer).await.is_some()
{
uncovered.push(peer);
}