diff options
| author | tv <tv@krebsco.de> | 2026-12-01 06:10:15 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 06:10:15 +0000 |
| commit | 82bb426dcd22268a960d35d7b8c947b864a6ddf5 (patch) | |
| tree | b407d8e840666b681d7b04d8b8e3b49e75b42ea6 /src/swarm/stability.rs | |
| parent | 81aa0ea92fbb9a84b484f9f9cf739047108e7697 (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/stability.rs')
| -rw-r--r-- | src/swarm/stability.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/swarm/stability.rs b/src/swarm/stability.rs index c163778..07ee1b3 100644 --- a/src/swarm/stability.rs +++ b/src/swarm/stability.rs @@ -39,7 +39,7 @@ const BRIEF_ABSENCE: Duration = Duration::from_secs(3600); /// How long after becoming ready we wait for a peer to tell us how long we were away. const AWAY_REPORT_GRACE: Duration = Duration::from_secs(30); /// A gap between two measurements longer than this means we didn't run (asleep). -const MAX_TICK_GAP: Duration = Duration::from_secs(30); +const MAX_TICK_GAP: Duration = Duration::from_secs(120); #[derive(Debug, Default)] pub(crate) struct Stability { @@ -157,6 +157,11 @@ pub(crate) fn away(state: &AppState, gap: Duration) { } } +/// Whether the tier this node found after a restart is decided (`tick`). +pub(crate) fn settled(state: &AppState) -> bool { + lock(state).settled +} + /// Measures, and updates our tier in the registry when it should change. Called every /// few seconds by the peer worker. pub(crate) async fn tick(state: &AppState) { |
