From 7b7dcb5a77061cb69d368de263a02b5ad26fbf51 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2026 04:20:52 +0100 Subject: unify lock logic --- src/simtest/mod.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/simtest') diff --git a/src/simtest/mod.rs b/src/simtest/mod.rs index e8e6e5b..408f53e 100644 --- a/src/simtest/mod.rs +++ b/src/simtest/mod.rs @@ -24,6 +24,7 @@ use tokio::time::Instant; use crate::document::replica::Epoch; use crate::document::store; use crate::files::Files; +use crate::locks::RwLockExt; use crate::node::{self, Node, NodeConfig}; use crate::state::{AppState, PeerState, Timing}; use crate::swarm::bootstrap::{self, Start}; @@ -198,14 +199,7 @@ impl Sim { node.initial_sync_done .load(std::sync::atomic::Ordering::Acquire), ); - let _ = writeln!( - out, - " view: {:?}", - *node - .neighbours - .read() - .unwrap_or_else(|poisoned| poisoned.into_inner()) - ); + let _ = writeln!(out, " view: {:?}", *node.neighbours.read_or_recover()); let peers: Vec<_> = node .peer_states .read() @@ -275,11 +269,7 @@ pub(crate) async fn heads(node: &AppState) -> Vec { /// Whether `node` has `peer` among its neighbours as computed from the member list. /// Before that list is known everyone counts as a neighbour, so this waits for it. pub(crate) fn has_neighbour(node: &AppState, peer: &str) -> bool { - node.neighbours - .read() - .unwrap_or_else(|poisoned| poisoned.into_inner()) - .is_some() - && crate::swarm::topology::is_neighbour(node, peer) + node.neighbours.read_or_recover().is_some() && crate::swarm::topology::is_neighbour(node, peer) } /// Something about `node`'s state for `peer`; None if it doesn't know the peer. -- cgit v1.3.1