aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/store/testfold.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-18 17:26:53 +0000
committertv <tv@krebsco.de>2026-11-18 18:31:11 +0100
commit598366b03679eac9d04f32d9194f3ba4ba9c3da8 (patch)
tree91620955243fa081fdd0365fb76c8aca0ba4288c /src/federation/store/testfold.rs
parentf261a80b88c1fb640f4c892934809e15a7e05a95 (diff)
store: a drop refuses whatever writes what a dropped event writes
A fold may say what an event writes that others may write alike (`Fold::writes`): of the federation, a version event's version. A node whose operator has it drop such an event drops the taken events writing the same with it, and refuses any writing it from then on, whoever wrote it anew: of a version, it takes no other version event naming it and writes none itself, though it holds the votes that passed it. The node keeps what each dropped event writes in its store file, across restarts; allowing one of them takes them all back. Row 51 of the federation's attacks has its test, and waits no more.
Diffstat (limited to 'src/federation/store/testfold.rs')
-rw-r--r--src/federation/store/testfold.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/federation/store/testfold.rs b/src/federation/store/testfold.rs
index bf23321..2478c0a 100644
--- a/src/federation/store/testfold.rs
+++ b/src/federation/store/testfold.rs
@@ -6,7 +6,8 @@
//! holds is its latest put, none other having it in its history, then the lowest ID.
//! * `lock`: a key locked for good.
//! * `era`: era `n`, taken only where `n` is one past the era at its history; of two of one
-//! number, a node keeps the first it takes (as the federation's versions).
+//! number, a node keeps the first it takes (as the federation's versions). Eras of one
+//! number and tag write the same: a drop of one refuses them all.
//! * `cut`: cut `n`, naming heads to move the store to, as `era`: above the heads the latest
//! cut of its history names, and holding that cut (or after the checkpoint the state
//! starts from, where it holds none); none of them in another's history. It must be above
@@ -362,6 +363,13 @@ impl Fold for TestFold {
}
}
+ fn writes(event: &[u8]) -> Option<Id> {
+ match decode(event)? {
+ (_, Kind::Era { n, tag }) => Some(Id::of(format!("era {n} {tag}").as_bytes())),
+ _ => None,
+ }
+ }
+
fn checkpoint(at: &State, heads: &[Id]) -> (Vec<u8>, Vec<Id>) {
let keeps: Vec<Id> = at.counting().into_values().collect();
let checkpoint = Checkpoint {