diff options
Diffstat (limited to 'src/state.rs')
| -rw-r--r-- | src/state.rs | 15 |
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"); } } |
