diff options
| author | tv <tv@krebsco.de> | 2026-11-20 01:28:41 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-20 02:38:56 +0100 |
| commit | 96a733e1ccbf6dab2d69f263d655e487ac54c20d (patch) | |
| tree | abfa6c292134a224b53e4a70c60a31721577a7bc /src/federation/client.rs | |
| parent | 7a178877d3b979ae6bd0e48ddb06363a0d50affc (diff) | |
federation: revision 2, the federation's name
A version may give its federation a name (`name`, spelled as a party's),
under a revision that has names: `federation-name`, revision 2. The
first version's is in the root, so a rehearsal named otherwise is
another federation, though its parties, keys, nodes and rules are the
same; a later version changes the name as anything else, which changes
what the federation is called, not which it is. A version giving a name
under an earlier revision is none.
What a version does says so, in words: it names the federation, renames
it, or drops its name. Half the generated histories begin at the newest
revision now, their versions naming the federation anew now and then;
those of the revisions before are generated as they were.
Diffstat (limited to 'src/federation/client.rs')
| -rw-r--r-- | src/federation/client.rs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/federation/client.rs b/src/federation/client.rs index ca2db86..74be7c8 100644 --- a/src/federation/client.rs +++ b/src/federation/client.rs @@ -433,8 +433,8 @@ pub(crate) fn backable(current: &Version, proposed: &Json) -> Result<Version, St /// What the version `proposed` does to `current`, in words, a line each: the parties it /// lets in or takes out, the keys and node lists it names anew, the rules it adds or drops, -/// the checkpoint it moves the store to, and the revision it moves to; what a party votes -/// on, without its JSON. Its number and the hash it changes go without saying. A node goes +/// the checkpoint it moves the store to, the revision it moves to, and the federation's +/// name it gives; what a party votes on, without its JSON. Its number and the hash it changes go without saying. A node goes /// by its name where `names` has one (`node_names`). pub(crate) fn described( current: &Version, @@ -492,6 +492,14 @@ pub(crate) fn described( if proposed.revision != current.revision { lines.push(format!("moves to {}", proposed.revision)); } + match (¤t.name, &proposed.name) { + (None, Some(name)) => lines.push(format!("names the federation {name}")), + (Some(was), Some(name)) if was != name => { + lines.push(format!("renames the federation {was} -> {name}")); + } + (Some(was), None) => lines.push(format!("drops the federation's name, {was}")), + _ => {} + } lines } @@ -1411,6 +1419,27 @@ mod tests { "moves to revision 1 (merge-events)".to_owned(), ] ); + let mut named = Spec::first(&[&tv, &lass], &rules); + named.revision = Revision::newest(); + named.name = Some("krebs".to_owned()); + assert_eq!( + described(¤t, &read(&named)), + [ + format!("moves to {}", Revision::newest()), + "names the federation krebs".to_owned(), + ] + ); + let mut renamed = named.clone(); + renamed.name = Some("krebs-test".to_owned()); + assert_eq!( + described(&read(&named), &read(&renamed)), + ["renames the federation krebs -> krebs-test"] + ); + renamed.name = None; + assert_eq!( + described(&read(&named), &read(&renamed)), + ["drops the federation's name, krebs"] + ); } /// Each hash is named by its shortest prefix no other has, of four digits at least, and |
