aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/revision.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-19 04:00:12 +0000
committertv <tv@krebsco.de>2026-11-19 05:13:38 +0100
commit0d2467e15ec0c9c035b1074a2dd4eece6b24c599 (patch)
treee544ce8ae1c31e9556191d3f99157b5bd61b1f14 /src/federation/revision.rs
parentefaf79e7fd55db2b9704ccefedde33346f874a1d (diff)
federation: revisions shown, named, and moved to by hand
An operator moving the federation to a revision had nothing to say which revisions a node knows, nor which one the current version follows, and a hash where a name would do. `GET /events` lists the revisions the node's continuum knows, each its number, its ID, the feature it adds and what that adds, and as people read it ("revision 1 (merge-events)"); `GET /events/counts`, the current version's. `continuum-party next --revision FEATURE` begins a version following the revision adding it, never an earlier one than the current version's, and `next` says so where the node knows a later one. `proposals` shows a change of revision as people read it, a revision this continuum doesn't know so said. A client backs a version moving to a revision only where its node knows it, and says why otherwise: once passed, a node that doesn't stops there. The upgrades guide walks through moving to a revision: upgrade every node, propose, vote, and what follows; the proposing guide lists `revision`, and the API's spec the rest.
Diffstat (limited to 'src/federation/revision.rs')
-rw-r--r--src/federation/revision.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/federation/revision.rs b/src/federation/revision.rs
index 3c6261b..7be6254 100644
--- a/src/federation/revision.rs
+++ b/src/federation/revision.rs
@@ -111,6 +111,22 @@ impl Revision {
}
}
+/// The revision a version's `revision` names (`named`, none for the base revision), as
+/// people read it: with its ID where it names one, and where this continuum doesn't know
+/// it, so said.
+pub(crate) fn described(named: Option<&Json>) -> String {
+ let Some(named) = named else {
+ return Revision::default().to_string();
+ };
+ match named.as_str().and_then(Id::from_hex) {
+ Some(id) => match Revision::of(&id) {
+ Some(revision) => format!("{revision}, {id}"),
+ None => format!("{id}, a revision this continuum doesn't know"),
+ },
+ None => "no revision's ID".to_owned(),
+ }
+}
+
/// As people read it: "the base revision", or "revision 2 (merge-events, …)".
impl fmt::Display for Revision {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -148,5 +164,13 @@ mod tests {
for revision in Revision::known() {
assert_eq!(Revision::of(&revision.id()), Some(revision));
}
+ assert_eq!(described(None), "the base revision");
+ let one = Json::Str(Revision(1).id().to_string());
+ assert_eq!(
+ described(Some(&one)),
+ format!("revision 1 (merge-events), {}", Revision(1).id())
+ );
+ let unknown = Json::Str(Id::of(b"elsewhere").to_string());
+ assert!(described(Some(&unknown)).ends_with("a revision this continuum doesn't know"));
}
}