aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/events.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-19 13:50:25 +0000
committertv <tv@krebsco.de>2026-11-19 14:53:47 +0100
commit7d91c37ec1c606f70ec7a90ce9be4b0aa5c518c4 (patch)
tree9116ed3a2fbc69cba32500d2b8b48f85c6d46c51 /src/api/events.rs
parentc1bf987314774d135316d95480baeb6eb7e1dc70 (diff)
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.
Diffstat (limited to 'src/api/events.rs')
-rw-r--r--src/api/events.rs31
1 files changed, 4 insertions, 27 deletions
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<AppState>) -> 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,