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.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,