diff options
Diffstat (limited to 'src/swarm')
| -rw-r--r-- | src/swarm/topology/mod.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/swarm/topology/mod.rs b/src/swarm/topology/mod.rs index afa13ee..37b2f71 100644 --- a/src/swarm/topology/mod.rs +++ b/src/swarm/topology/mod.rs @@ -117,7 +117,7 @@ pub(crate) fn is_full_mesh(state: &AppState) -> bool { } /// The current view in numbers, once known. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone)] pub(crate) struct Summary { /// Registered members, us included. pub(crate) members: usize, @@ -126,6 +126,10 @@ pub(crate) struct Summary { pub(crate) stable: usize, pub(crate) neighbours: usize, pub(crate) stable_neighbours: usize, + /// For each of our transports (address scheme), the neighbours the member list + /// gives an address on it: one on two transports counts on both, one it gives none + /// for (not listed yet, or only connecting out) on none. + pub(crate) neighbours_by_transport: BTreeMap<String, usize>, } pub(crate) fn summary(state: &AppState) -> Option<Summary> { @@ -148,6 +152,22 @@ pub(crate) fn summary(state: &AppState) -> Option<Summary> { .iter() .filter(|m| view.stable.contains(*m)) .count(), + neighbours_by_transport: view + .local_transports + .iter() + .map(|transport| { + let on_it = view + .neighbours + .iter() + .filter(|m| { + view.transports + .get(*m) + .is_some_and(|theirs| theirs.contains(transport)) + }) + .count(); + (transport.clone(), on_it) + }) + .collect(), }) } |
