aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/links.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 21:12:50 +0100
committertv <tv@krebsco.de>2026-10-31 21:12:50 +0100
commita0c6850d85e1f8f1d9613a323df12d1c94cce8f6 (patch)
treebf4dae1e16c6d78c7810f0d3dfefbd0b06014382 /src/swarm/links.rs
parentbf33537e04177dd22b6dc6777182ed241e8bdc71 (diff)
links report down
Diffstat (limited to 'src/swarm/links.rs')
-rw-r--r--src/swarm/links.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/swarm/links.rs b/src/swarm/links.rs
index 3e4d717..e3c1b56 100644
--- a/src/swarm/links.rs
+++ b/src/swarm/links.rs
@@ -122,6 +122,11 @@ pub(crate) async fn own_links(state: &AppState) -> Vec<Link> {
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
@@ -390,6 +395,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)
@@ -411,6 +417,7 @@ mod tests {
peer: peer.into(),
transport: Some("libp2p".into()),
relayed: false,
+ down: false,
rtt_us,
dormant: false,
others: Vec::new(),
@@ -429,6 +436,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.