diff options
| author | tv <tv@krebsco.de> | 2026-10-24 04:50:16 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 04:52:09 +0200 |
| commit | 6b046a5c18d670c3097b8563c191a2dc06ce1179 (patch) | |
| tree | 4515a699ff621dd6e6dd2376624f5903106b41c0 /src/api | |
| parent | 6fa188610ce0959e0b61ecaf63f5babf826d2071 (diff) | |
record RTT from keepalive messages
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/peers.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/api/peers.rs b/src/api/peers.rs index d381395..3893e0f 100644 --- a/src/api/peers.rs +++ b/src/api/peers.rs @@ -62,6 +62,9 @@ pub(crate) struct PeerStatus { heads: Option<usize>, /// We keep it alive and sync with it on our own; other peers we only answer. neighbour: bool, + /// Smoothed round-trip time in milliseconds, from PING/PONG and HELLO/HELLO_REPLY; + /// absent until measured. + rtt_ms: Option<f64>, } #[derive(Debug, Serialize, ToSchema)] @@ -109,6 +112,10 @@ pub(crate) async fn list_peers( for (public_key, peer_state_mutex) in snapshot { let neighbour = crate::swarm::topology::is_neighbour(&state, &public_key); + let rtt_ms = state + .lock_rtt() + .get(&public_key) + .map(|rtt| rtt.as_secs_f64() * 1000.0); let ps = peer_state_mutex.lock().await; let (status, dormant_for_secs) = match ps.liveness { @@ -133,6 +140,7 @@ pub(crate) async fn list_peers( same_epoch: ps.epoch.map(|epoch| epoch == local_epoch), heads: ps.reported_heads, neighbour, + rtt_ms, }); } |
