aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/topology/graph.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-06 19:53:27 +0100
committertv <tv@krebsco.de>2026-11-06 19:53:27 +0100
commit7c0c318dca3054be6c7bacf5a4b3f5a4e47cc949 (patch)
tree8baa20fcef0b22f21f05d91c282b3613c546d98f /src/swarm/topology/graph.rs
parentdbff95968b859b2f879442dfc5c4b5bbf916ad96 (diff)
topology neighbours and optional graph
Diffstat (limited to 'src/swarm/topology/graph.rs')
-rw-r--r--src/swarm/topology/graph.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/swarm/topology/graph.rs b/src/swarm/topology/graph.rs
index 92240e9..d8b2921 100644
--- a/src/swarm/topology/graph.rs
+++ b/src/swarm/topology/graph.rs
@@ -34,8 +34,8 @@ pub(crate) fn schemes(addresses: &[String]) -> BTreeSet<String> {
/// The neighbours of `local` among `members` (by the transports each is on), on each of
/// `local_transports`: on each, its neighbours among the members on it
/// (`neighbours`), all together.
-pub(crate) fn neighbours_across(
- topology: &dyn Topology,
+pub(crate) fn neighbours_across<T: Topology + ?Sized>(
+ topology: &T,
members: &BTreeMap<String, BTreeSet<String>>,
local: &str,
local_transports: &BTreeSet<String>,
@@ -56,9 +56,10 @@ pub(crate) fn neighbours_across(
}
/// The neighbours of `local` among `members` (which may or may not contain `local`),
-/// skipping members for which `unreachable` holds.
-pub(crate) fn neighbours(
- topology: &dyn Topology,
+/// skipping members for which `unreachable` holds; none by a topology without a shared
+/// graph.
+pub(crate) fn neighbours<T: Topology + ?Sized>(
+ topology: &T,
members: &[String],
local: &str,
k: usize,
@@ -69,7 +70,7 @@ pub(crate) fn neighbours(
all.push(local.to_owned());
topology
.graph(&all, k, &|m: &str| m != local && unreachable(m), stable)
- .remove(local)
+ .and_then(|mut graph| graph.remove(local))
.unwrap_or_default()
}
@@ -88,8 +89,8 @@ impl Topology for RingAndPairs {
k: usize,
unreachable: &dyn Fn(&str) -> bool,
stable: &dyn Fn(&str) -> bool,
- ) -> BTreeMap<String, BTreeSet<String>> {
- graph(members, k, unreachable, stable)
+ ) -> Option<BTreeMap<String, BTreeSet<String>>> {
+ Some(graph(members, k, unreachable, stable))
}
}