diff options
| author | tv <tv@krebsco.de> | 2026-11-25 13:03:52 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-25 13:03:52 +0000 |
| commit | 1656f73b41a3528048c33774457b0d68ed430934 (patch) | |
| tree | 56fa9550232e9831f1f2d6ed324d9b16b9d713cf /src/federation/held.rs | |
| parent | 1820e326115f803ffa84280aad4e367f20d91e9f (diff) | |
store: a new event builds on a head holding what it is judged by
A new event builds on the heads taken earliest, 64 at most. Where a
store holds more, and those all come from before the current version was
written, an event on them is written under the version before: a merge
event, under one without merge events, was refused, so the backlog of
heads a revision was passed to merge stayed, and with more heads than a
checkpoint may name, no node proposed one.
The fold now says which events a new one is to have in its history
(Fold::judged_by; the federation: those writing the current version),
and building_on names the earliest head holding one, in place of the
last of the others.
Diffstat (limited to 'src/federation/held.rs')
| -rw-r--r-- | src/federation/held.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/federation/held.rs b/src/federation/held.rs index cf3cf04..72633eb 100644 --- a/src/federation/held.rs +++ b/src/federation/held.rs @@ -2210,6 +2210,51 @@ mod tests { assert!(holding.merge(&listed).is_empty()); } + /// Heads from before the version naming the revision with merge events, more than an + /// event may name: a merge event on the earliest of them alone would be written under + /// the version before, which has none, and refused. It builds on one holding the + /// current version too, so the backlog a revision was passed for gets merged. + #[test] + fn a_node_merges_heads_older_than_the_revision() { + let (tv, lass) = (Party::new("tv", 1), Party::new("lass", 2)); + let first = Spec::first(&[&tv, &lass], &[]); + let root = first.root(); + let on = first.hash(); + let mut doc = events::started(Federation::NAME, &root, &[]).unwrap(); + for n in 0..=event::DEPENDENCIES { + put( + &mut doc, + &tv.write( + &[Id::of(&root)], + &format!("home/tv/k{n}"), + harness::str("1"), + ), + ); + } + let holding = + Holding::open(None, Arc::new(Files::default()), None, Some("tv".into())).unwrap(); + read(&holding, &doc, 0); + // The revision passes: its version event is the head taken last. + let mut next = first.after(on); + next.revision = Feature::MergeEvents.revision(); + let proposal = tv.propose(&[Id::of(&root)], &next.json()); + let votes = + [&tv, &lass].map(|party| party.vote(&[Id::of(&proposal)], on, next.hash(), true)); + let written = harness::version_event(&[Id::of(&votes[0]), Id::of(&votes[1])], next.hash()); + for event in [&proposal, &votes[0], &votes[1], &written] { + put(&mut doc, event); + } + read(&holding, &doc, 0); + assert_eq!( + holding.with(|store| store.state().current().hash), + Some(next.hash()) + ); + let listed = crate::identity::NodeKey::from_seed([128; 32]); + assert!(holding.apart(&listed)); + assert!(!holding.merge(&listed).is_empty()); + assert!(!holding.apart(&listed)); + } + /// Row 70 (`docs/federation.md`): a checkpoint's version proposed again, by an event /// beside its heads. A node backs it all the same, as a proposal lapses with the move, /// and votes on the event proposing it above the heads alone: a version event written |
