From 7d91c37ec1c606f70ec7a90ce9be4b0aa5c518c4 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 13:50:25 +0000 Subject: peers: what each peer said it speaks and knows, in GET /peers GET /peers shows, of each peer, what it said with its handshakes (SPEAKS): its `knows`, the wire versions it speaks, the oldest and the newest, and the newest revision of the federation it knows; null where it said nothing, a build from before SPEAKS or no handshake from it since the node started. `localKnows` is the node's own. So every swarm, federated or not, shows which builds its nodes run, as far as each heard. `swarm::speaking::shown` shapes it, for GET /events/counts too, whose `knows` is the same; docs/openapi.yaml has it once, as `Knows`. Without the federation feature, a revision reads as one this continuum doesn't know. `Speaking::of` is now used in every build, not only federated ones, which warned of it as dead code. --- src/api/events.rs | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'src/api/events.rs') diff --git a/src/api/events.rs b/src/api/events.rs index f49c540..45c9a32 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -106,39 +106,16 @@ 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. +/// What `node` says it speaks and knows (SPEAKS, `swarm::speaking::shown`), this node's +/// own as it is; 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, - }) + speaks.map_or(JsonValue::Null, crate::swarm::speaking::shown) } /// The revisions this continuum knows, the base revision first: each its number, its ID, -- cgit v1.3.1