From f85298c40c2528ee801c14a10a7db8920b50fdf8 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 14:09:05 +0000 Subject: 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. --- src/federation/fold.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/federation/fold.rs') diff --git a/src/federation/fold.rs b/src/federation/fold.rs index d832976..46dad27 100644 --- a/src/federation/fold.rs +++ b/src/federation/fold.rs @@ -350,9 +350,21 @@ impl State { ballots } - /// The checkpoint's version: the one current where the store moved there, or started. - pub(crate) fn checkpoint_version(&self) -> &Version { - &self.versions[&self.checkpoint] + /// How many versions were written since the checkpoint's that change more than moving + /// to a checkpoint: the one that moved the store there counts not. + pub(crate) fn changed_since_checkpoint(&self) -> u64 { + let mut count = 0; + let mut version = self.current(); + while version.hash != self.checkpoint { + let Some(before) = version.changes.and_then(|hash| self.versions.get(&hash)) else { + break; + }; + if !version.only_moves_on(before) { + count += 1; + } + version = before; + } + count } /// The version the proposal of hash `proposal` proposes, as JSON, where it holds one: -- cgit v1.3.1