aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/event.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 18:03:39 +0000
committertv <tv@krebsco.de>2026-11-16 19:07:40 +0100
commit0231b7732b8c005e956a5b112c0e4fdddc38429e (patch)
tree10da30c741a44156b9a1fde1ed2297197f1a180f /src/federation/event.rs
parentd61ebc07db70d9f03b1d74b03712cea9310b05a7 (diff)
federation: the federation as the store's fold
`Federation` is the store's fold for `docs/federation.md`. The state judging reads is the state of an event's history, which the store builds from the checkpoint and that history alone; so the version current there is the state's, the highest-numbered one written, and a history holding two versions of one number is refused. * A signed event's party is a party of the version current at its history. A write is signed by a key among its party's (those of its key set that counts, else those its version names) where a rule gives its party the place; a key set, node list, proposal or vote by a key its version names. * A vote is on the version current at its history, for a proposal proposed on it; a `true` only where every other proposal its party backs on that version is dead. Passing and dead go by the parties voting each way, a party with both counting for both. * A version event writes a proposal on the version current at its history, passed there, which is a version changing that one; one naming a checkpoint names heads after the current checkpoint at which it is current too, none in another's history, the version event above them. A node keeps a version event only where it changes the version it reads, or writes one it took. * What counts is read by the current version: of each party's writes at a place it may write, signed by a key among its party's, and of its key sets and node lists written under a version at least their `since`, the latest, then the lowest ID. A checkpoint keeps what counts at its heads and the proposals and votes on the version current there; a fork's root what counts at its heads by its version; the members are the nodes each party's node list names. Tests take a federation through writes, a key set, a proposal passing, one yes at a time, two versions changing one, a checkpoint and a node starting from it, and a fork. Events are read with their signature checked once, where they are judged.
Diffstat (limited to 'src/federation/event.rs')
-rw-r--r--src/federation/event.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/federation/event.rs b/src/federation/event.rs
index b8e89f1..fc519d0 100644
--- a/src/federation/event.rs
+++ b/src/federation/event.rs
@@ -53,6 +53,16 @@ impl Event {
/// back to itself, the signature doesn't hold, or it is larger than federation 1
/// allows.
pub(crate) fn read(bytes: &[u8]) -> Option<Event> {
+ Self::parse(bytes, true)
+ }
+
+ /// The event `bytes` are, as `read` reads them, but for its signature, which isn't
+ /// checked: for bytes a store took already, whose signature held then.
+ pub(crate) fn read_taken(bytes: &[u8]) -> Option<Event> {
+ Self::parse(bytes, false)
+ }
+
+ fn parse(bytes: &[u8], verify: bool) -> Option<Event> {
if bytes.len() > LARGEST {
return None;
}
@@ -81,7 +91,7 @@ impl Event {
return None;
}
let sig = json.get("sig")?.as_str()?;
- if !keys::verifies(&public, sig, &json.without("sig").bytes()) {
+ if verify && !keys::verifies(&public, sig, &json.without("sig").bytes()) {
return None;
}
let what = json.get(does)?;