diff options
Diffstat (limited to 'src/swarm/links.rs')
| -rw-r--r-- | src/swarm/links.rs | 11 |
1 files changed, 9 insertions, 2 deletions
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<String> { } /// 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<OtherPath> { let mut others: Vec<OtherPath> = Vec::new(); for path in destination.map_or(&[][..], |destination| &destination.paths[..]) { @@ -119,14 +120,20 @@ fn others(destination: Option<&Destination>, used: Option<&str>) -> Vec<OtherPat .rtt_ms .filter(|ms| ms.is_finite() && *ms >= 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)); |
