aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-30 18:29:01 +0100
committertv <tv@krebsco.de>2026-10-30 18:29:01 +0100
commitc33ba31c0d27c3f2531fe9f5ac5dbe55326c8349 (patch)
tree36411002a2a66b0c83893923736bf387255409aa /src/swarm
parente3b386c2aa9970f2f999f07ac43b7eb8fe319d8d (diff)
links answers connection type
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/links.rs11
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));