From c33ba31c0d27c3f2531fe9f5ac5dbe55326c8349 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Oct 2026 18:29:01 +0100 Subject: links answers connection type --- src/swarm/links.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/swarm') diff --git a/src/swarm/links.rs b/src/swarm/links.rs index d7df0d5..04f2e2d 100644 --- a/src/swarm/links.rs +++ b/src/swarm/links.rs @@ -105,7 +105,8 @@ fn scheme_of(address: &str) -> Option { } /// The transports besides `used` the peer proved itself at, with a path up: each with -/// the round trip of its fastest path, if any is measured. +/// the round trip of its fastest path, if any is measured, and whether all of them go +/// through a relay. fn others(destination: Option<&Destination>, used: Option<&str>) -> Vec { let mut others: Vec = Vec::new(); for path in destination.map_or(&[][..], |destination| &destination.paths[..]) { @@ -119,14 +120,20 @@ fn others(destination: Option<&Destination>, used: Option<&str>) -> Vec= 0.0) .map(|ms| (ms * 1000.0).min(f64::from(u32::MAX)) as u32); + let relayed = path.connection == Some(Connection::Relayed); match others.iter_mut().find(|other| other.transport == transport) { Some(other) => { other.rtt_us = match (other.rtt_us, rtt_us) { (Some(a), Some(b)) => Some(a.min(b)), (a, b) => a.or(b), }; + other.relayed &= relayed; } - None => others.push(OtherPath { transport, rtt_us }), + None => others.push(OtherPath { + transport, + rtt_us, + relayed, + }), } } others.sort_by(|a, b| a.transport.cmp(&b.transport)); -- cgit v1.3.1