aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/store/testfold.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 17:10:41 +0000
committertv <tv@krebsco.de>2026-11-16 18:28:20 +0100
commit8f6ec848b01fa692b09ae8aae25d383d281eb996 (patch)
treefdfd1a03b55802cb667c55b68b3c70817c413e91 /src/federation/store/testfold.rs
parente7f8b368db441dbd2c91b08e7e04fa34bed01a1a (diff)
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.
Diffstat (limited to 'src/federation/store/testfold.rs')
-rw-r--r--src/federation/store/testfold.rs15
1 files changed, 3 insertions, 12 deletions
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<u8>, Vec<Id>), Refused> {
+ fn fork(at: &State, heads: &[Id], spec: &[u8]) -> Result<(Vec<u8>, Vec<Id>), Refused> {
let (era, tag): (u64, String) =
serde_json::from_slice(spec).map_err(|_| Refused::new("no spec"))?;
- let mut counting: BTreeMap<String, Id> = 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<Id> = counting.into_values().collect();
+ let keeps: Vec<Id> = 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))