diff options
| author | tv <tv@krebsco.de> | 2026-10-31 03:48:38 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 03:48:38 +0100 |
| commit | 725110193bf2d8acc43a6951decc75d155352a46 (patch) | |
| tree | aab5304b1a63c32ee7a6921f95126cc76c5ef16d | |
| parent | c6d16c416fde16463d9fec2ab18f9fb929852dc7 (diff) | |
unify RTT source
| -rw-r--r-- | src/swarm/links.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/swarm/links.rs b/src/swarm/links.rs index 80e6833..5938986 100644 --- a/src/swarm/links.rs +++ b/src/swarm/links.rs @@ -118,8 +118,10 @@ pub(crate) async fn own_links(state: &AppState) -> Vec<Link> { relayed: destination .as_ref() .is_some_and(|destination| destination.connection == Some(Connection::Relayed)), - rtt_us: rtt_of(destination.as_ref()) - .or_else(|| state.transport.rtt(&peer)) + // The path in use's (`Transport::rtt`, the first of `destination.paths`). + rtt_us: state + .transport + .rtt(&peer) .map(|rtt| u32::try_from(rtt.as_micros()).unwrap_or(u32::MAX)), dormant, peer, @@ -172,16 +174,6 @@ fn others(destination: Option<&Destination>, used: Option<&str>) -> Vec<OtherPat others } -/// The round-trip time of the path messages to the peer go over (`destination`'s -/// first path, best first), if measured: `Transport::rtt` takes the first address the -/// peer proved itself at, which needn't be the one in use. -fn rtt_of(destination: Option<&Destination>) -> Option<Duration> { - let path = destination?.paths.first()?; - path.rtt_ms - .filter(|ms| ms.is_finite() && *ms >= 0.0) - .map(|ms| Duration::from_secs_f64(ms / 1000.0)) -} - /// Asks `member` for its links (a LINKS), and with `subscribe` for its changes for /// that long; its replies land in `AppState::links`. #[cfg_attr(not(feature = "dashboard"), allow(dead_code))] |
