aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/events.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/api/events.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/api/events.rs')
-rw-r--r--src/api/events.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/api/events.rs b/src/api/events.rs
index b13de63..7bb322e 100644
--- a/src/api/events.rs
+++ b/src/api/events.rs
@@ -21,6 +21,7 @@ use crate::federation::client;
use crate::federation::fold::Federation;
use crate::federation::fork;
use crate::federation::jcs::Json as Jcs;
+use crate::federation::revision::Revision;
use crate::federation::store::Id;
use crate::federation::store::memory::{Offered, Refusal, Store};
use crate::state::AppState;
@@ -83,8 +84,8 @@ fn why(refusal: &Refusal) -> String {
/// `GET /events`: the store's ID, its checkpoint's, its heads, as many as an event may
/// name, what a new event builds on (`Store::building_on`), how many events it took
-/// after its checkpoint, the event it stopped at, if any, the node's party, and whether
-/// the node votes for it by itself.
+/// after its checkpoint, the event it stopped at, if any, the node's party, whether the
+/// node votes for it by itself, and the revisions of the federation its continuum knows.
async fn summary(State(state): State<AppState>) -> Response {
let party = state.holding.party().map(str::to_owned);
let votes = state.holding.votes_by_itself();
@@ -100,10 +101,28 @@ async fn summary(State(state): State<AppState>) -> Response {
"stopped": stopped,
"party": party,
"votesByItself": votes,
+ "revisions": revisions(),
})
})
}
+/// The revisions this continuum knows, the base revision first: each its number, its ID,
+/// the feature it adds and what that adds, and as people read it.
+fn revisions() -> Vec<JsonValue> {
+ Revision::known()
+ .map(|revision| {
+ let adds = revision.features().last();
+ json!({
+ "number": revision.0,
+ "id": revision.id().to_string(),
+ "feature": adds.map(|feature| feature.name()),
+ "adds": adds.map(|feature| feature.what()),
+ "named": revision.to_string(),
+ })
+ })
+ .collect()
+}
+
/// `GET /events/{id}`: an event the store holds, taken or kept by its checkpoint, or its
/// checkpoint, as its bytes.
async fn event(State(state): State<AppState>, Path(id): Path<String>) -> Response {
@@ -186,6 +205,11 @@ async fn counts(State(state): State<AppState>) -> Response {
"version": {
"number": current.number,
"hash": current.hash.to_string(),
+ "revision": {
+ "number": current.revision.0,
+ "id": current.revision.id().to_string(),
+ "named": current.revision.to_string(),
+ },
"version": plain(&current.json),
},
"parties": parties,