aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/peer/worker.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 20:38:27 +0100
committertv <tv@krebsco.de>2026-11-01 20:38:27 +0100
commit6d9b462e1bb1e2ebbda6c0dcdcfe22a15d4b4cbe (patch)
tree73a7ece5215045c374ed3b928a8d36b220d50e19 /src/swarm/peer/worker.rs
parentdbb614e1ecf27ca37f54dba4e2c8fe3810af8c8c (diff)
peer worker forget records on change
Diffstat (limited to 'src/swarm/peer/worker.rs')
-rw-r--r--src/swarm/peer/worker.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/swarm/peer/worker.rs b/src/swarm/peer/worker.rs
index 546f867..e8e6f8b 100644
--- a/src/swarm/peer/worker.rs
+++ b/src/swarm/peer/worker.rs
@@ -1,7 +1,8 @@
//! The peer worker: keepalives due, dormancy, HELLO retries and overdue sync replies,
//! when the earliest of them is due (or something may have made one due sooner,
//! `Due`); every `FORGET_CHECK_INTERVAL` (and at once when the node becomes ready),
-//! forget records, the member registry, stability, measurements and the state file.
+//! forget records, the member registry, stability, measurements and the state file;
+//! forget records also at once when they changed.
use std::time::Duration;
@@ -152,8 +153,14 @@ pub(crate) async fn run_peer_worker(state: AppState) {
.unwrap_or(next);
}
- if last_forget_check.is_none_or(|t| t.elapsed() >= FORGET_CHECK_INTERVAL) {
+ let records_changed = state
+ .forget_records_changed
+ .swap(false, std::sync::atomic::Ordering::AcqRel);
+ let periodic = last_forget_check.is_none_or(|t| t.elapsed() >= FORGET_CHECK_INTERVAL);
+ if records_changed || periodic {
apply_forget_records(&state, &mut forgets_applied).await;
+ }
+ if periodic {
forget_strangers(&state).await;
crate::swarm::members::ensure_registered(&state).await;
crate::swarm::stability::tick(&state).await;