diff options
| author | tv <tv@krebsco.de> | 2026-11-19 14:09:05 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-19 15:18:42 +0100 |
| commit | f85298c40c2528ee801c14a10a7db8920b50fdf8 (patch) | |
| tree | 1eef6e26be145d819b5280142f9a6aa277ec4b3f /src/federation/vote.rs | |
| parent | 59d8d6f9c4f539ac9392872026d99a93f66102ee (diff) | |
vote: the version that moved the store counts not toward the next checkpoint
`--store-propose-versions` counted the versions since the checkpoint's
version, the one current at its heads. The version that moved the store
there is written after its heads, so it counted: with 1, a node proposed
a checkpoint again as soon as it backed one (`--store-back-after` after
the move), and the next one, and so on, every ten minutes for good.
It counts the versions written since that change more than moving to a
checkpoint now (`State::changed_since_checkpoint`): with 1, one
checkpoint after every other version, and none after a checkpoint. The
test goes on past the move.
Diffstat (limited to 'src/federation/vote.rs')
| -rw-r--r-- | src/federation/vote.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/federation/vote.rs b/src/federation/vote.rs index 4ba2e8f..7000b40 100644 --- a/src/federation/vote.rs +++ b/src/federation/vote.rs @@ -49,7 +49,8 @@ pub(crate) struct Rules { pub(crate) propose_events: Option<usize>, /// ...or so long after the store moved to it, by its own clock... pub(crate) propose_every: Option<Duration>, - /// ...or once so many versions were written since the one it holds. + /// ...or once so many versions were written since the one it holds, of those changing + /// more than moving to a checkpoint. pub(crate) propose_versions: Option<u64>, /// How long it holds an event before it holds it for a while: the voters' rule, and how /// long a new proposal holds back a checkpoint. @@ -421,7 +422,7 @@ pub(crate) fn by_hand( /// what is written after does. fn checkpoint(seen: &Seen<'_>, rules: &Rules, current: &Version, all: &[Proposed]) -> Option<Json> { let store = seen.store; - let since = current.number - store.state().checkpoint_version().number; + let since = store.state().changed_since_checkpoint(); let due = rules .propose_events .is_some_and(|events| store.taken().len() >= events) @@ -836,6 +837,15 @@ mod tests { let version = Version::read(json).unwrap(); assert_eq!(version.checkpoint, Some(vec![written])); assert_eq!(version.changes, Some(next.hash())); + // Once the store moved there, the version that moved it counts not: none again. + let on = next.hash(); + let proposal = taken(&mut store, tv.propose(&[written], json)); + let votes = [&tv, &lass] + .map(|party| taken(&mut store, party.vote(&[proposal], on, version.hash, true))); + taken(&mut store, harness::version_event(&votes, version.hash)); + assert_eq!(store.state().current().hash, version.hash); + assert_eq!(store.state().changed_since_checkpoint(), 0); + assert!(decide(&seen(&store, &long), &rules, &record).is_empty()); } /// A node proposes a checkpoint at the heads its store holds, the one it took a moment |
