aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-03 03:30:19 +0100
committertv <tv@krebsco.de>2026-11-03 03:30:19 +0100
commitbdb76a07c824f3775c5eb92d2754f8f239ccdf70 (patch)
tree6cc9270c3ba0de7c7465b0ddf495f945ce6d0b14 /src/swarm
parent5b3d9cbd1bba986b06978bef0100d349b33e74c7 (diff)
dashboard: show eager links on the map
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/links.rs24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/swarm/links.rs b/src/swarm/links.rs
index c430d58..e0d483d 100644
--- a/src/swarm/links.rs
+++ b/src/swarm/links.rs
@@ -1,8 +1,9 @@
//! How members are linked, for a map of the swarm (the dashboard, `api::dashboard`): a
//! node asks a member with LINKS, and the member answers with a LINKS_REPLY listing its
//! neighbours and the peers it holds dormant (`own_links`), each with the transport its
-//! messages go over, whether only through a relay, the round trip and whether it is
-//! dormant: as the member measures them, which no other node can.
+//! messages go over, whether only through a relay, the round trip, whether it is
+//! dormant, and which way the link is eager (`swarm::relay`): as the member measures
+//! them, which no other node can.
//!
//! Every node answers, whatever its build: one with a dashboard asks any member, which
//! may have none. Only members (in the member list) are answered, as the links name
@@ -10,8 +11,8 @@
//! is written to the document: asked for while someone looks, forgotten after.
//!
//! A LINKS may subscribe (`subscribe_secs`): the member then sends a LINKS_REPLY again
-//! whenever its links change (`changed`: a peer, a transport, relayed, dormant, or a
-//! round trip that moved by a fifth), looked at every `WATCH_EVERY` while anyone
+//! whenever its links change (`changed`: a peer, a transport, relayed, dormant, eager,
+//! or a round trip that moved by a fifth), looked at every `WATCH_EVERY` while anyone
//! subscribes (round trips change without telling), until the subscription runs out
//! (the asker renews it with its next LINKS, so one that is gone stops it by not
//! renewing) or a LINKS with 0 ends it.
@@ -231,7 +232,14 @@ impl Links {
pub(crate) async fn own_links(state: &AppState) -> Vec<Link> {
let mut links = Vec::new();
for (peer, peer_state) in state.peers_snapshot().await {
- let dormant = peer_state.lock().await.liveness.is_dormant();
+ let (dormant, eager_to, eager_from) = {
+ let peer_state = peer_state.lock().await;
+ (
+ peer_state.liveness.is_dormant(),
+ peer_state.eager_to,
+ peer_state.eager_from,
+ )
+ };
if !dormant && !topology::is_neighbour(state, &peer) {
continue;
}
@@ -256,6 +264,8 @@ pub(crate) async fn own_links(state: &AppState) -> Vec<Link> {
.rtt(&peer)
.map(|rtt| u32::try_from(rtt.as_micros()).unwrap_or(u32::MAX)),
dormant,
+ eager_to,
+ eager_from,
clock: state.transport.clock_offset(&peer),
peer,
});
@@ -1010,6 +1020,8 @@ fn changed(old: &[Link], new: &[Link]) -> bool {
|| a.relayed != b.relayed
|| a.down != b.down
|| a.dormant != b.dormant
+ || a.eager_to != b.eager_to
+ || a.eager_from != b.eager_from
|| moved(a.rtt_us, b.rtt_us)
|| clock_moved(a.clock, b.clock)
|| a.others.len() != b.others.len()
@@ -1062,6 +1074,8 @@ mod tests {
down: false,
rtt_us,
dormant: false,
+ eager_to: false,
+ eager_from: false,
others: Vec::new(),
clock: None,
}