diff options
| author | tv <tv@krebsco.de> | 2026-10-31 06:51:17 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 06:51:17 +0100 |
| commit | 88160e8aa273090c55103e7a92eeae9a8bdac9ed (patch) | |
| tree | ad1d23dafbf808dfcf1a07552e4e9a47d41ffa74 /src/api/peers.rs | |
| parent | 32c788b4d6245abebafb250b005a211fcbeac32c (diff) | |
calculate peer clock drift
Diffstat (limited to 'src/api/peers.rs')
| -rw-r--r-- | src/api/peers.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/api/peers.rs b/src/api/peers.rs index 020221b..3fe4c39 100644 --- a/src/api/peers.rs +++ b/src/api/peers.rs @@ -18,6 +18,7 @@ use crate::locks::MutexExt; use crate::state::{AppState, HelloState, Incidents, Liveness}; use crate::swarm::peer::forgotten_path; use crate::transport::Destination; +use crate::transport::paths::ClockOffset; use crate::transport::traffic::PeerTraffic; #[derive(Debug, Serialize)] @@ -66,6 +67,9 @@ pub(crate) struct PeerStatus { /// Smoothed sync throughput (`swarm::throughput`); absent before the first large /// exchange. pub(crate) sync_throughput: Option<ThroughputInfo>, + /// How far its clock is ahead of ours, give or take (`Transport::clock_offset`); + /// absent before a PONG from it. + pub(crate) clock: Option<ClockOffset>, } #[derive(Debug, Serialize)] @@ -141,6 +145,7 @@ pub(crate) async fn peer_list(state: &AppState) -> PeerListResponse { let alias = aliases.remove(&peer); let addresses = state.transport.addresses_of(&peer); let destination = state.transport.destination(&peer); + let clock = state.transport.clock_offset(&peer); peers.insert( peer, PeerStatus { @@ -168,6 +173,7 @@ pub(crate) async fn peer_list(state: &AppState) -> PeerListResponse { traffic, incidents: ps.incidents, sync_throughput, + clock, }, ); } |
