summaryrefslogtreecommitdiffstats
path: root/src/simtest/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/simtest/mod.rs')
-rw-r--r--src/simtest/mod.rs16
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.