diff options
| author | tv <tv@krebsco.de> | 2026-10-24 04:16:56 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 04:16:56 +0200 |
| commit | 5710d1a367a1914d09e0eefe6984408c95a7dd2e (patch) | |
| tree | 435e85ca3ea017c52ad4055c6a810ea685a1acf5 /src/state.rs | |
| parent | b92128a93bc86908290fe3d2a9a424054857535c (diff) | |
sync with neighbours
Diffstat (limited to 'src/state.rs')
| -rw-r--r-- | src/state.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/state.rs b/src/state.rs index cfa5ddf..64fe6a4 100644 --- a/src/state.rs +++ b/src/state.rs @@ -321,6 +321,14 @@ impl PeerState { false } + /// No more HELLO retries (the peer isn't our neighbour any more). A HELLO in flight + /// finishes; a later handshake starts over. + pub(crate) fn stop_hello_retries(&mut self) { + if matches!(self.hello_state, HelloState::AwaitingReply { .. }) { + self.hello_state = HelloState::NotSent; + } + } + /// Moves a silent peer to Dormant. Returns true on the transition. pub(crate) fn check_dormancy(&mut self, timing: &Timing, now: Instant) -> bool { if self.liveness != Liveness::Active || self.quiet_for(now) < timing.dormant_after { @@ -495,6 +503,12 @@ pub(crate) struct AppState { /// Random per run of this node; our HELLOs carry it and replies must echo it. pub(crate) run_id: transport::RunId, + /// Target number of neighbours (`--neighbours`); up to this many + 1 members the + /// swarm is a full mesh. + pub(crate) neighbours_k: usize, + /// Our neighbours, once known (`swarm::topology`). + pub(crate) neighbours: Arc<std::sync::RwLock<Option<crate::swarm::topology::NeighbourView>>>, + /// While rejoining a newer epoch, the previous document, served read-only (and /// marked stale) instead of answering 503. pub(crate) stale: Arc<std::sync::RwLock<Option<StaleView>>>, @@ -751,6 +765,10 @@ impl AppState { let local = self.local_epoch(); let mut announce = Vec::new(); for (id, peer_state_mutex) in &peers { + // Others learn it from their own neighbours. + if !crate::swarm::topology::is_neighbour(self, id) { + continue; + } let mut peer_state = peer_state_mutex.lock().await; // What it said about syncing with us was about our old epoch. peer_state.syncs_with_us = None; |
