From 9164ebfe9a4014cbbaaaff90c5a1d722e39457fd Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 13:34:24 +0000 Subject: federation: which nodes know a revision, in counts and before a `true` `GET /events/counts` says, of each node a party lists, what it said it speaks and knows (`knows`, by node ID): the wire versions, the oldest and the newest, and the newest revision of the federation it knows, by number and ID and as people read it, its number null where this continuum doesn't know it; null where it said nothing, a build from before SPEAKS or one the node didn't hear from; the node's own as it is. So the nodes still to upgrade before a revision passes show, every party's, where before a party's operators could check only their own. A party's client, backing a proposal that moves to another revision, warns of every node of any party not known to know it, a line a party naming each and what it said: once it passes, those stop at it till upgraded. `next` warns alike, of the revision it moves to, or of the later one it suggests. A warning, not a refusal: what a node heard is no proof, and a node not heard from may well be upgraded. --- src/api/events.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'src/api') diff --git a/src/api/events.rs b/src/api/events.rs index 7bb322e..f49c540 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -106,6 +106,41 @@ async fn summary(State(state): State) -> Response { }) } +/// What `node` says it speaks and knows (SPEAKS, `swarm::speaking`), this node's own as +/// it is: the wire versions it speaks, the oldest and the newest, and the newest revision +/// of the federation it knows, by number and ID and as people read it, its number null +/// where this continuum doesn't know it. Null where the node said nothing: a build from +/// before SPEAKS, or one not heard from. +fn knows(state: &AppState, node: &str) -> JsonValue { + let speaks = if node == state.local_id() { + Some(crate::swarm::speaking::own()) + } else { + state.speaking.of(node) + }; + let Some(speaks) = speaks else { + return JsonValue::Null; + }; + let revision = speaks.revision.map(|id| { + let id = Id(id); + match Revision::of(&id) { + Some(revision) => json!({ + "number": revision.0, + "id": id.to_string(), + "named": revision.to_string(), + }), + None => json!({ + "number": null, + "id": id.to_string(), + "named": format!("{id}, a revision this continuum doesn't know"), + }), + } + }); + json!({ + "wire": [speaks.oldest, speaks.newest], + "revision": revision, + }) +} + /// 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 { @@ -143,7 +178,8 @@ async fn event(State(state): State, Path(id): Path) -> Respons } /// `GET /events/counts`: what counts, as the store reads now: the current version, each -/// party's keys and nodes, the values at places, the members, and the proposals on the +/// party's keys and nodes, what each of those nodes says it speaks and knows (`knows`), +/// the values at places, the members, and the proposals on the /// current version, each with the events proposing it a vote may build on (`proposing`: /// for a checkpoint, those above its heads), the votes on it, the parties /// voting `true` and `false`, whether it passed and whether it is dead, and why a party's @@ -157,11 +193,17 @@ async fn counts(State(state): State) -> Response { .parties .keys() .map(|party| { + let nodes = read.nodes_of(party, current); + let knows: serde_json::Map = nodes + .iter() + .map(|node| (node.clone(), knows(&state, node))) + .collect(); ( party.clone(), json!({ "keys": read.keys_of(party, current), - "nodes": read.nodes_of(party, current), + "nodes": nodes, + "knows": knows, }), ) }) -- cgit v1.3.1