aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/peer/worker.rs
diff options
context:
space:
mode:
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;