aboutsummaryrefslogtreecommitdiffstats
path: root/src/state/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-01 06:10:15 +0000
committertv <tv@krebsco.de>2026-12-01 06:10:15 +0000
commit82bb426dcd22268a960d35d7b8c947b864a6ddf5 (patch)
treeb407d8e840666b681d7b04d8b8e3b49e75b42ea6 /src/state/mod.rs
parent81aa0ea92fbb9a84b484f9f9cf739047108e7697 (diff)
swarm: the peer worker's periodic checks run when something happened, and rarely when quietHEADmaster
Every five seconds the peer worker looked at the forget records, the member registry, stability, whom the node reaches, its links, its clock, its measurements and the state file. It now looks five seconds after the document or a peer's state changed, every five seconds while something of these is under way (the node not ready or catching up, a forget record not acted on, a link's change not settled, the tier after a restart not decided, a neighbour not reached), and once a minute otherwise, for what changes with time alone. Stability takes two measurements more than two minutes apart for the node not having run.
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 fe71b7b..e815550 100644
--- a/src/state/mod.rs
+++ b/src/state/mod.rs
@@ -244,6 +244,9 @@ 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>,
+ /// Something happened that the peer worker's periodic checks may have to act on
+ /// (`swarm::peer::worker`): the document or a peer's state changed.
+ pub(crate) housekeeping: Arc<tokio::sync::Notify>,
/// A peer said another epoch than this node's (`swarm::peer::epoch`): the remake
/// worker looks whether to follow it (`remake::switch`).
pub(crate) remake_wake: Arc<tokio::sync::Notify>,
@@ -589,10 +592,12 @@ impl AppState {
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();
+ self.housekeeping.notify_one();
Arc::new(Mutex::new(PeerState::new(leads, &self.timing)))
}
pub(crate) fn notify_store_changed(&self) {
+ self.housekeeping.notify_one();
self.change_tx.send_modify(|version| {
*version = version.wrapping_add(1);
});