From 4e0d0312a591fd55e3dabbf5fa6dd9f00408c045 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 21:12:50 +0100 Subject: links report down --- src/swarm/links.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/swarm') diff --git a/src/swarm/links.rs b/src/swarm/links.rs index d5238f3..8502b39 100644 --- a/src/swarm/links.rs +++ b/src/swarm/links.rs @@ -122,6 +122,11 @@ pub(crate) async fn own_links(state: &AppState) -> Vec { relayed: destination .as_ref() .is_some_and(|destination| destination.connection == Some(Connection::Relayed)), + // Ranked up before down: the first is down only if all are. + down: destination + .as_ref() + .and_then(|destination| destination.paths.first()) + .is_some_and(|path| path.down), // The path in use's (`Transport::rtt`, the first of `destination.paths`). rtt_us: state .transport @@ -377,6 +382,7 @@ fn changed(old: &[Link], new: &[Link]) -> bool { a.peer != b.peer || a.transport != b.transport || a.relayed != b.relayed + || a.down != b.down || a.dormant != b.dormant || moved(a.rtt_us, b.rtt_us) || clock_moved(a.clock, b.clock) @@ -398,6 +404,7 @@ mod tests { peer: peer.into(), transport: Some("libp2p".into()), relayed: false, + down: false, rtt_us, dormant: false, others: Vec::new(), @@ -416,6 +423,9 @@ mod tests { let mut dormant = link("a", Some(10_000)); dormant.dormant = true; assert!(changed(&old, &[dormant])); + let mut down = link("a", Some(10_000)); + down.down = true; + assert!(changed(&old, &[down])); // Small round trips: a millisecond's wobble isn't news. assert!(!changed(&[link("a", Some(400))], &[link("a", Some(1_300))])); // A clock: news when measured, and when it moved beyond both bounds. -- cgit v1.3.1