aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/events.rs
diff options
context:
space:
mode:
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,