aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/topology.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-28 14:03:53 +0100
committertv <tv@krebsco.de>2026-10-28 14:03:53 +0100
commit86104f5aa4fa6d8cbc0ea2c5d47481e23c3aff04 (patch)
treee969237e0d7614f884d544e23f675df7209e5c97 /src/swarm/topology.rs
parenteddf62d7a202a0b8b95df28d769e62fe23622b7a (diff)
add support for renaming IDs in the logger
Diffstat (limited to 'src/swarm/topology.rs')
-rw-r--r--src/swarm/topology.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/swarm/topology.rs b/src/swarm/topology.rs
index c9d1266..2ba07b7 100644
--- a/src/swarm/topology.rs
+++ b/src/swarm/topology.rs
@@ -137,6 +137,19 @@ pub(crate) fn affects_neighbours(path: &[String]) -> bool {
path.is_empty() || path.starts_with(&members::members_dir())
}
+/// Hands the members' `aliases` to the logger, under every name that stands for each:
+/// its node ID, and its addresses (`logging`, which renames them bare too).
+fn set_aliases(state: &AppState, aliases: std::collections::HashMap<String, String>) {
+ let mut names = std::collections::HashMap::new();
+ for (member, alias) in aliases {
+ for address in state.transport.identities_of(&member) {
+ names.insert(address, alias.clone());
+ }
+ names.insert(member, alias);
+ }
+ crate::logging::set_aliases(names);
+}
+
/// Recomputes the neighbours once ready, if the member list, the reachable members or
/// `k` changed.
pub(crate) async fn refresh(state: &AppState) -> Option<NeighbourChange> {
@@ -146,6 +159,7 @@ pub(crate) async fn refresh(state: &AppState) -> Option<NeighbourChange> {
let (current, stable, transports, alive) = {
let replica = state.doc.read().await;
members::learn_addresses(state, &replica.doc);
+ set_aliases(state, members::aliases(&replica.doc));
let current = members::members(&replica.doc);
// Those that said they are alive within the electorate window.
let alive: BTreeSet<String> = members::electorate(