aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/peer/forget.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/swarm/peer/forget.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/swarm/peer/forget.rs')
-rw-r--r--src/swarm/peer/forget.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/swarm/peer/forget.rs b/src/swarm/peer/forget.rs
index b911993..5eb5026 100644
--- a/src/swarm/peer/forget.rs
+++ b/src/swarm/peer/forget.rs
@@ -41,6 +41,21 @@ fn forgotten_peers(doc: &(impl Read + ?Sized)) -> Vec<String> {
/// The forget records this node acted on: peer → the record as it read then.
pub(super) type AppliedForgets = HashMap<String, JsonValue>;
+/// Whether a forget record of a peer this node knows is not acted on yet (`applied`):
+/// the peer was alive, and is looked at again.
+pub(super) async fn unapplied(state: &AppState, applied: &AppliedForgets) -> bool {
+ let forgotten = forgotten_peers(&state.doc.read().await.doc);
+ for peer in forgotten {
+ if peer != state.local_id()
+ && !applied.contains_key(&peer)
+ && state.get_peer_state(&peer).await.is_some()
+ {
+ return true;
+ }
+ }
+ false
+}
+
/// Acts on each forget record once (`applied`). A peer forgotten here may be heard of
/// again before its cancel arrives (named in a peer list, or alive again), and is kept
/// then; forgetting it again every check would only make it flap. A new record (another