aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/revision.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/federation/revision.rs')
-rw-r--r--src/federation/revision.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/federation/revision.rs b/src/federation/revision.rs
index 7be6254..2e5464d 100644
--- a/src/federation/revision.rs
+++ b/src/federation/revision.rs
@@ -16,6 +16,9 @@ pub(crate) enum Feature {
/// Merge events: a node its party lists, with its own key, builds on events it holds,
/// writing nothing (`Does::Merge`).
MergeEvents,
+ /// The federation's name, in its versions (`Version::name`): the first version's, in
+ /// the root, parts it from a federation of a first version alike otherwise.
+ FederationName,
}
impl Feature {
@@ -24,6 +27,7 @@ impl Feature {
pub(crate) fn name(self) -> &'static str {
match self {
Feature::MergeEvents => "merge-events",
+ Feature::FederationName => "federation-name",
}
}
@@ -34,6 +38,10 @@ impl Feature {
"merge events, which a node its party lists signs with its own key, building \
on events it holds and writing nothing"
}
+ Feature::FederationName => {
+ "the federation's name, which a version gives it and a later one changes: the \
+ first version's, in the root, parts it from a federation alike otherwise"
+ }
}
}
@@ -49,7 +57,7 @@ impl Feature {
/// The features, in the order revisions add them: revision n has the first n, the base
/// revision none. Only ever appended to.
-pub(crate) const FEATURES: &[Feature] = &[Feature::MergeEvents];
+pub(crate) const FEATURES: &[Feature] = &[Feature::MergeEvents, Feature::FederationName];
/// A revision: how many of `FEATURES` it has.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
@@ -158,6 +166,14 @@ mod tests {
Id::of(br#"["merge-events"]"#),
"a released revision's ID changes never"
);
+ assert_eq!(
+ Revision(2).id(),
+ Id::of(br#"["merge-events","federation-name"]"#)
+ );
+ assert_eq!(
+ Feature::FederationName.revision().to_string(),
+ "revision 2 (merge-events, federation-name)"
+ );
let names: Vec<&str> = FEATURES.iter().map(|feature| feature.name()).collect();
let distinct: std::collections::BTreeSet<&str> = names.iter().copied().collect();
assert_eq!(distinct.len(), names.len(), "a feature named twice");