diff options
| author | tv <tv@krebsco.de> | 2026-12-01 03:23:21 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 03:45:00 +0000 |
| commit | b6743899468db6304173aca4c7b32d05ea8d92c9 (patch) | |
| tree | 96036989bc0bba94364cdf1b6a3aba73c3e8ae28 /src/state | |
| parent | 80a1075951bdf70a4e9fb68e4a4228cfe0d27ba8 (diff) | |
remake: the switch worker looks when something changed, not every second
It read the remake records and its peers' epochs once a second, whatever
happened. It now looks when the records change, within a second of a
peer saying another epoch than this node's, and when a vote is due; and
by itself, once a second, only while something waits on time: a remake
of this epoch open or committed, a rejoin, a catch-up, a member on
another epoch. What it keeps for a time, an archived document or a
remake's content, it wakes for when that is due.
Diffstat (limited to 'src/state')
| -rw-r--r-- | src/state/host.rs | 5 | ||||
| -rw-r--r-- | src/state/mod.rs | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/state/host.rs b/src/state/host.rs index 66bb71c..9f6ff2b 100644 --- a/src/state/host.rs +++ b/src/state/host.rs @@ -371,6 +371,11 @@ impl Host for AppState { crate::swarm::source::reset(self); } + fn remake_woken(&self) -> impl Future<Output = ()> + Send { + let wake = Arc::clone(&self.remake_wake); + async move { wake.notified().await } + } + fn subscribe_changes(&self) -> broadcast::Receiver<Arc<ChangeSet>> { self.change_events.subscribe() } diff --git a/src/state/mod.rs b/src/state/mod.rs index c3bb4e8..fe71b7b 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>, + /// 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>, /// The forget records may have changed (`swarm::changes`): the peer worker acts on /// them at once instead of at its next periodic check. pub(crate) forget_records_changed: Arc<AtomicBool>, |
