aboutsummaryrefslogtreecommitdiffstats
path: root/src/state/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 20:36:17 +0100
committertv <tv@krebsco.de>2026-11-01 20:36:17 +0100
commite293047c25d7167f25af0a611b33545f12225b05 (patch)
tree51d31d9538cc2b1d988dd1b4faa6a5cc65c33f05 /src/state/mod.rs
parent962fe4b43632822dc91fa6a4da6f6f295f4dba32 (diff)
peer worker sleeps until deadline, not fixed time
Diffstat (limited to 'src/state/mod.rs')
-rw-r--r--src/state/mod.rs5
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)))
}