aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/properties.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-20 01:28:41 +0000
committertv <tv@krebsco.de>2026-11-20 02:38:56 +0100
commit96a733e1ccbf6dab2d69f263d655e487ac54c20d (patch)
treeabfa6c292134a224b53e4a70c60a31721577a7bc /src/federation/properties.rs
parent7a178877d3b979ae6bd0e48ddb06363a0d50affc (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/properties.rs')
-rw-r--r--src/federation/properties.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/federation/properties.rs b/src/federation/properties.rs
index 2b824f0..dce0984 100644
--- a/src/federation/properties.rs
+++ b/src/federation/properties.rs
@@ -108,7 +108,7 @@ fn generate(rng: &mut Rng, kind: Kind) -> History {
}
/// A history of `kind`, its first version following `revision`, or, where none is given,
-/// the base revision or one with merge events alike.
+/// the base revision or the newest alike.
pub(super) fn generate_at(rng: &mut Rng, kind: Kind, revision: Option<Revision>) -> History {
let count = rng.between(3, 5);
let parties: Vec<Party> = (0..count)
@@ -117,13 +117,18 @@ pub(super) fn generate_at(rng: &mut Rng, kind: Kind, revision: Option<Revision>)
let adversary = count - 1;
let refs: Vec<&Party> = parties.iter().collect();
let mut first = Spec::first(&refs, &[("names/{party}", harness::str("{party}"))]);
- // Half the federations begin at a revision with merge events, which nodes then sign.
- let merging = rng.chance(0.5);
- first.revision = revision.unwrap_or(if merging {
- Feature::MergeEvents.revision()
+ // Half the federations begin at the newest revision: with merge events, which nodes
+ // then sign, and a name, which versions change.
+ let newest = rng.chance(0.5);
+ first.revision = revision.unwrap_or(if newest {
+ Revision::newest()
} else {
Revision::default()
});
+ let naming = first.revision.has(Feature::FederationName);
+ if naming {
+ first.name = Some("f".to_owned());
+ }
let root = first.root();
let root_id = Id::of(&root);
let mut world: Store<Federation> = Store::new(root.clone(), Vec::new()).expect("a root");
@@ -204,6 +209,8 @@ pub(super) fn generate_at(rng: &mut Rng, kind: Kind, revision: Option<Revision>)
let head = *deps.iter().find(|dep| **dep != root_id).expect("one");
next.checkpoint = Some(vec![head]);
deps = vec![head];
+ } else if naming && rng.chance(0.3) {
+ next.name = Some(format!("f{step}"));
} else {
next.rules
.push((format!("names/x{step}"), harness::str(&party.name)));