diff options
| author | tv <tv@krebsco.de> | 2026-10-31 05:21:24 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 05:21:24 +0100 |
| commit | ba64c49fda6f2b4c9eb91eb3d311bdf9b9b98954 (patch) | |
| tree | f4b520b4eb5b8da89d01bfe7efe38c97c69223a0 /src | |
| parent | 20b0be670d3798d63ccf36d0fb014c64e7b729b7 (diff) | |
unify usage of is_dormant
Diffstat (limited to 'src')
| -rw-r--r-- | src/simtest/timing.rs | 8 | ||||
| -rw-r--r-- | src/swarm/sync.rs | 4 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/simtest/timing.rs b/src/simtest/timing.rs index 0752f2f..0f19313 100644 --- a/src/simtest/timing.rs +++ b/src/simtest/timing.rs @@ -7,7 +7,7 @@ use serde_json::json; use super::{Sim, has_neighbour, heads, peer, read, write}; use crate::document::replica::Epoch; -use crate::state::{AppState, Liveness}; +use crate::state::AppState; use crate::swarm::bootstrap::Start; use crate::transport::sim::LinkParams; use crate::transport::{HeadsSummary, HelloRequest, MessageKind, ParsedMessage, RunId, Status}; @@ -232,11 +232,7 @@ async fn peer_goes_dormant_and_returns() { } async fn is_dormant(node: &AppState, other: &str) -> bool { - peer(node, other, |p| { - matches!(p.liveness, Liveness::Dormant { .. }) - }) - .await - == Some(true) + peer(node, other, |p| p.liveness.is_dormant()).await == Some(true) } /// R27: a resent HELLO (its reply was lost) or a late copy of one doesn't reset the diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs index b34c20b..51144ac 100644 --- a/src/swarm/sync.rs +++ b/src/swarm/sync.rs @@ -11,7 +11,7 @@ use tokio::time::Instant; use tracing::{debug, info, trace, warn}; use crate::locks::MutexExt; -use crate::state::{AppState, Liveness, PeerState, Standing}; +use crate::state::{AppState, PeerState, Standing}; use crate::swarm::peer::{peer_swarm, send_hello_once}; use crate::swarm::source; use crate::swarm::throughput::SyncBytes; @@ -42,7 +42,7 @@ async fn deliver_sync_to_peer(state: &AppState, peer: &str) -> Result<()> { let validated_swarm = { let peer_state = peer_state_mutex.lock().await; - if matches!(peer_state.liveness, Liveness::Dormant { .. }) { + if peer_state.liveness.is_dormant() { // Reactivation re-handshakes, and PeerValidated then restarts sync. trace!("Skipping sync with dormant peer"); return Ok(()); |
