diff options
| author | tv <tv@krebsco.de> | 2026-11-19 14:11:39 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-19 15:18:45 +0100 |
| commit | 27b76d5748f23a879d9fc82c725a58b514020ef9 (patch) | |
| tree | d0201eed80c9c4a2db3f2e6281cac51dbc126ba6 /src/federation/fork.rs | |
| parent | 8347900a553a3c4c9f9d3fc4a539fd31b41b07d3 (diff) | |
fork: a fork's check says what its version changes, rules among it
A node holding the history up to a fork's heads said whether it builds
the root, what it holds that those heads lack, and which parties' keys
the fork's version gives otherwise. A founder could change the rules, or
only their order, which says who writes where, and nobody joining was
shown it.
The check now says what the fork's version changes of the version
current at those heads, a line each as a proposal's are shown
(`client::changes`): `changes` in POST /events/fork, and
`continuum-party check` prints them. federation.md and the forking
guide say so, and that a fork's ID is compared whole: a founder trying
versions can steer its first few digits.
Diffstat (limited to 'src/federation/fork.rs')
| -rw-r--r-- | src/federation/fork.rs | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/federation/fork.rs b/src/federation/fork.rs index 59b744f..c5ce727 100644 --- a/src/federation/fork.rs +++ b/src/federation/fork.rs @@ -1,9 +1,10 @@ //! Forks (`docs/federation.md`, Forks): a node holding a federation's history makes the //! root of a fork at heads it holds, by a version (`make`), and checks one it is given //! (`check`): whether it builds that root at its heads, what it holds that those heads -//! lack, and, party by party, the keys the fork's version gives where they aren't the -//! keys the party had there. A node that doesn't hold that history takes a fork's root on -//! its operator's word, who names the fork by its root's ID (`--store-id`). +//! lack, what the fork's version changes of the one current there, and, party by party, +//! the keys the fork's version gives where they aren't the keys the party had there. A +//! node that doesn't hold that history takes a fork's root on its operator's word, who +//! names the fork by its root's ID (`--store-id`). //! //! A fork's founders start its swarm from a file holding its root on the first line, and //! the events the root keeps, each on a line of its own (`--store-root`): JCS writes no @@ -60,14 +61,18 @@ pub(crate) struct Check { /// What it holds that those heads lack: events it took that are neither among them, /// nor in their history, nor above them. pub(crate) lacking: Vec<Id>, + /// What the fork's version changes of the version current at those heads, a line each + /// (`client::changes`): its rules among them, whose order says who writes where. + pub(crate) changes: Vec<String>, /// Each party whose keys the fork's version gives otherwise than the party had at /// those heads, with its keys there and in the fork. pub(crate) keys: Vec<(String, Vec<String>, Vec<String>)>, } /// What `store` finds of the fork whose root is `root`: as a node holding the history up -/// to its heads builds it, says what it holds that those heads lack, and, party by party, -/// whether the fork's version gives it the keys it had there. +/// to its heads builds it, says what it holds that those heads lack, what the fork's +/// version changes of the one current there, and, party by party, whether it gives the +/// party the keys it had there. pub(crate) fn check(store: &Store<Federation>, root: &[u8]) -> Result<Check, String> { let checkpoint = Checkpoint::read(root).ok_or("no checkpoint, so no fork's root")?; if checkpoint.at.is_empty() { @@ -84,12 +89,14 @@ pub(crate) fn check(store: &Store<Federation>, root: &[u8]) -> Result<Check, Str builds, why, lacking: Vec::new(), + changes: Vec::new(), keys: Vec::new(), }); } let lacking = store.left_out(heads, store.taken()); let at = store.state_at(heads); let current = at.current(); + let changes = super::client::changes(¤t.json, &version.json); let sorted = |mut keys: Vec<String>| { keys.sort(); keys @@ -121,6 +128,7 @@ pub(crate) fn check(store: &Store<Federation>, root: &[u8]) -> Result<Check, Str builds, why, lacking, + changes, keys, }) } @@ -148,12 +156,20 @@ mod tests { assert_eq!(read_root_file(&first.root()), (first.root(), Vec::new())); assert!(make(&store, &[Id::of(b"not held")], &spec.json()).is_err()); let check = check(&store, &root).unwrap(); + // What the fork's version changes: what it changes, tv's node list, its number. + let [changes, nodes, number] = check.changes.as_slice() else { + panic!("{:?}", check.changes); + }; + assert_eq!(*changes, format!("changes: null -> \"{}\"", first.hash())); + assert!(nodes.starts_with("nodes.tv: ") && nodes.ends_with(r#""since":1}"#)); + assert_eq!(number, "number: 0 -> 1"); assert_eq!( check, Check { builds: true, why: None, lacking: Vec::new(), + changes: check.changes.clone(), keys: Vec::new(), } ); |
