From 0d2467e15ec0c9c035b1074a2dd4eece6b24c599 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 04:00:12 +0000 Subject: 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. --- src/federation/revision.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/federation/revision.rs') 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")); } } -- cgit v1.3.1