From 6b046a5c18d670c3097b8563c191a2dc06ce1179 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2026 04:50:16 +0200 Subject: record RTT from keepalive messages --- src/state.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/state.rs') diff --git a/src/state.rs b/src/state.rs index 10471df..2bc9264 100644 --- a/src/state.rs +++ b/src/state.rs @@ -536,6 +536,8 @@ pub(crate) struct AppState { /// Target number of neighbours (`--neighbours`); up to this many + 1 members the /// swarm is a full mesh. pub(crate) neighbours_k: usize, + /// Round-trip times to peers (`swarm::rtt`). + pub(crate) rtt: Arc>, /// The neighbour we are pulling changes from, and since when (`swarm::relay`). pub(crate) pulling: Arc>>, /// Our neighbours, once known (`swarm::topology`). @@ -566,6 +568,12 @@ impl AppState { self.transport.local_id() } + pub(crate) fn lock_rtt(&self) -> std::sync::MutexGuard<'_, crate::swarm::rtt::RttTable> { + self.rtt + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()) + } + /// The local epoch. Code that labels or applies sync messages must use the epoch /// of the locked `Replica` instead, so label and document can't disagree. pub(crate) fn local_epoch(&self) -> Epoch { @@ -814,12 +822,7 @@ impl AppState { } for id in announce { - let keepalive = crate::swarm::peer::local_keepalive(self, id).await; - if let Err(error) = self - .transport - .send_message(id, &transport::ParsedMessage::Ping(keepalive)) - .await - { + if let Err(error) = crate::swarm::peer::send_ping(self, id).await { debug!(peer = %id, error = %format!("{error:#}"), "Epoch announcement failed"); } } -- cgit v1.3.1