summaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-24 04:50:16 +0200
committertv <tv@krebsco.de>2026-10-24 04:52:09 +0200
commit6b046a5c18d670c3097b8563c191a2dc06ce1179 (patch)
tree4515a699ff621dd6e6dd2376624f5903106b41c0 /src/state.rs
parent6fa188610ce0959e0b61ecaf63f5babf826d2071 (diff)
record RTT from keepalive messages
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs15
1 files changed, 9 insertions, 6 deletions
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<std::sync::Mutex<crate::swarm::rtt::RttTable>>,
/// The neighbour we are pulling changes from, and since when (`swarm::relay`).
pub(crate) pulling: Arc<std::sync::Mutex<Option<(String, Instant)>>>,
/// 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");
}
}