From 8f6ec848b01fa692b09ae8aae25d383d281eb996 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 17:10:41 +0000 Subject: federation: groups that parted come together as parties come in, not by merges A merge, a fork at heads of several stores, named every party's keys anew, so that a party wrote its key set again before anything a key of its set signed counted there; and kept each side's values side by side, so that a value a party replaced on one side came back where the other side's write had the lower ID. Letting the other side's parties in, by a version or a fork naming them, who sign again what they keep as a party's client signs again what a move refused, does the same with nothing new. So a fork is at heads of one store: the fold makes its root from that store's state, and the store from its own heads (`Store::fork`). Merges' rows go, those after them move up, and Roads not taken says why, with merging in place. --- src/federation/store/testfold.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/federation/store/testfold.rs') diff --git a/src/federation/store/testfold.rs b/src/federation/store/testfold.rs index 094c424..bbe0307 100644 --- a/src/federation/store/testfold.rs +++ b/src/federation/store/testfold.rs @@ -406,19 +406,10 @@ impl Fold for TestFold { Ok(state) } - fn fork(at: &[&State], heads: &[Id], spec: &[u8]) -> Result<(Vec, Vec), Refused> { + fn fork(at: &State, heads: &[Id], spec: &[u8]) -> Result<(Vec, Vec), Refused> { let (era, tag): (u64, String) = serde_json::from_slice(spec).map_err(|_| Refused::new("no spec"))?; - let mut counting: BTreeMap = BTreeMap::new(); - let mut locks = BTreeSet::new(); - for state in at { - for (key, id) in state.counting() { - let lowest = counting.entry(key).or_insert(id); - *lowest = (*lowest).min(id); - } - locks.extend(state.locks.iter().cloned()); - } - let keeps: Vec = counting.into_values().collect(); + let keeps: Vec = at.counting().into_values().collect(); let root = Checkpoint { name: String::new(), at: hex(heads.iter().copied()), @@ -426,7 +417,7 @@ impl Fold for TestFold { era, tag, cut: 0, - locks: locks.into_iter().collect(), + locks: at.locks.iter().cloned().collect(), }; let bytes = serde_json::to_vec(&root).expect("a root encodes"); Ok((bytes, keeps)) -- cgit v1.3.1