diff options
| author | tv <tv@krebsco.de> | 2026-10-26 04:20:52 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-26 04:20:52 +0100 |
| commit | 7b7dcb5a77061cb69d368de263a02b5ad26fbf51 (patch) | |
| tree | d3255ce629cb60059cb55191dc206d0f64ca645e /src/simtest | |
| parent | d668ce2ff8f308e54c1c7a2c145cb3479cab899d (diff) | |
unify lock logic
Diffstat (limited to 'src/simtest')
| -rw-r--r-- | src/simtest/mod.rs | 16 |
1 files changed, 3 insertions, 13 deletions
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<ChangeHash> { /// 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. |
