diff options
| author | tv <tv@krebsco.de> | 2026-11-01 20:36:17 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-01 20:36:17 +0100 |
| commit | dbb614e1ecf27ca37f54dba4e2c8fe3810af8c8c (patch) | |
| tree | ac7c141812d534f3c51907e5634fcb6c8aadc468 /src/state/mod.rs | |
| parent | 7f018573730dc57f9608fe41faa54b44abba841d (diff) | |
peer worker sleeps until deadline, not fixed time
Diffstat (limited to 'src/state/mod.rs')
| -rw-r--r-- | src/state/mod.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/state/mod.rs b/src/state/mod.rs index 2902234..ba90269 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -154,6 +154,8 @@ pub(crate) struct AppState { /// Something a joining node waits for may have happened: the swarm ID learned, the /// initial sync done, a rejoin ended, a seed found (`swarm::bootstrap`). pub(crate) join_progress: Arc<tokio::sync::Notify>, + /// When the peer worker is next due (`swarm::peer::Due`). + pub(crate) peers_due: Arc<crate::swarm::peer::Due>, /// While rejoining a newer epoch, the previous document, served read-only (and /// marked stale) instead of answering 503. @@ -319,6 +321,8 @@ impl AppState { let old_lifecycle = lifecycle.clone(); *lifecycle = NodeLifecycle::Ready { swarm_id }; debug!("Node transitioned from {old_lifecycle:?} {lifecycle:?}"); + // Dormancy is judged once ready, and the periodic checks run at once. + self.peers_due.now(); } NodeLifecycle::Ready { swarm_id: existing } if existing == &swarm_id => { debug!("Node already ready with the same identity"); @@ -366,6 +370,7 @@ impl AppState { /// State for a peer we haven't known so far (not inserted). pub(crate) fn new_peer_state(&self, pk: &str) -> Arc<Mutex<PeerState>> { let leads = crate::swarm::pair::leads(self.local_id(), pk); + self.peers_due.now(); Arc::new(Mutex::new(PeerState::new(leads, &self.timing))) } |
