diff options
| author | tv <tv@krebsco.de> | 2026-10-31 05:45:57 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 05:45:57 +0100 |
| commit | 197cee7f4da41a8f5181e314a90a26ae93e23a63 (patch) | |
| tree | 105791a86d30f27e9af63165ec7f3c4228b26e75 /src/state | |
| parent | ca0bd76db94e5d561f5c30b7b211e865d9e9e494 (diff) | |
centralize call to topology_change
Diffstat (limited to 'src/state')
| -rw-r--r-- | src/state/mod.rs | 2 | ||||
| -rw-r--r-- | src/state/peer.rs | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/state/mod.rs b/src/state/mod.rs index 8f3a841..a2d5d74 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -143,7 +143,7 @@ pub(crate) struct AppState { /// Our neighbours, once known (`swarm::topology`). pub(crate) neighbours: Arc<std::sync::RwLock<Option<crate::swarm::topology::NeighbourView>>>, /// Something the neighbours are computed from may have changed: the member list or a - /// peer's reachability (`swarm::topology::run_worker`). + /// peer's state (`swarm::topology::run_worker`, `swarm::topology::change_peer`). pub(crate) topology_changed: Arc<tokio::sync::Notify>, /// While rejoining a newer epoch, the previous document, served read-only (and diff --git a/src/state/peer.rs b/src/state/peer.rs index 95a9dc3..99f912b 100644 --- a/src/state/peer.rs +++ b/src/state/peer.rs @@ -288,6 +288,19 @@ impl PeerState { self.unreachable_since.is_some() } + /// What choosing neighbours reads of this peer (`swarm::topology::refresh`): whether + /// it is unreachable, whether it was ever heard from, whether it is a member, and + /// whether it syncs with us. A change to any may change the neighbours + /// (`swarm::topology::change_peer`). + pub(crate) fn neighbour_inputs(&self) -> impl PartialEq + use<> { + ( + self.is_unreachable(), + self.last_seen.is_some(), + matches!(self.standing, Standing::Member { .. }), + self.syncs_with_us, + ) + } + /// The wait before the next HELLO: a probe's if unreachable. pub(crate) fn next_hello_wait(&mut self) -> Duration { if self.is_unreachable() { |
