diff options
| author | tv <tv@krebsco.de> | 2026-11-20 00:55:34 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-20 02:15:09 +0100 |
| commit | e31d93577ccefdf540fd3df518a7d9837cb20cbb (patch) | |
| tree | 791c441a2a1936badf7056e7429748fef1367460 /src/federation/party/status.rs | |
| parent | 637a8603775d02ef014ec84491a2bbbb5c7c4f54 (diff) | |
continuum-party: nodes by their names wherever it shows them
A node goes by the name it gave itself (`--alias`), as `names` in
`GET /events/counts` shows it, in what a proposal does (`show`,
`proposals`, `status`, before a vote), among the nodes not known to know
a revision, and at the head of `status`'s section on the node it asks,
which now names that node by its ID too. A node no party lists yet has no
name there: only members' entries reach the node.
Diffstat (limited to 'src/federation/party/status.rs')
| -rw-r--r-- | src/federation/party/status.rs | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/federation/party/status.rs b/src/federation/party/status.rs index 4c637fa..47c32e5 100644 --- a/src/federation/party/status.rs +++ b/src/federation/party/status.rs @@ -114,6 +114,9 @@ async fn model(node: &Node, options: &Options, party: Option<&str>) -> Result<Js }, "node": { "id": summary["node"], + "name": summary["node"] + .as_str() + .and_then(|id| client::node_names(&counts).remove(id)), "party": summary["party"], "votesByItself": summary["votesByItself"], "revisions": revisions, @@ -448,7 +451,20 @@ fn render(model: &JsonValue, paint: &Paint) -> Vec<String> { } let node = &model["node"]; - out.push(heading("the node")); + // A node's name after its ID, where it gave itself one. + let named = |node: &JsonValue| match node["name"].as_str() { + Some(name) => format!(" ({})", paint.paint(Style::Name, name)), + None => String::new(), + }; + out.push(match node["id"].as_str() { + Some(id) => format!( + "{} {}{}", + heading("the node"), + paint.paint(Style::Id, id), + named(node) + ), + None => heading("the node"), + }); out.push(match node["party"].as_str() { Some(party) => format!( " {}'s{}", @@ -521,13 +537,10 @@ fn render(model: &JsonValue, paint: &Paint) -> Vec<String> { out.push(" nodes:".to_owned()); } for node in &nodes { - let name = match node["name"].as_str() { - Some(name) => format!(" ({})", paint.paint(Style::Name, name)), - None => String::new(), - }; out.push(format!( - " {}{name}", - paint.paint(Style::Id, &text(&node["id"])) + " {}{}", + paint.paint(Style::Id, &text(&node["id"])), + named(node) )); let heard = match node["heard"].as_u64() { _ if node["here"].as_bool() == Some(true) => paint.paint(Style::Good, "this node"), @@ -759,7 +772,13 @@ mod tests { json!({ "format": FORMAT, "store": {"id": "6d1e", "checkpoint": "6d1e", "heads": 3, "taken": 1, "stopped": null}, - "node": {"party": "lass", "votesByItself": true, "revisions": ["the base revision"]}, + "node": { + "id": "continuum:9c07", + "name": "beta", + "party": "lass", + "votesByItself": true, + "revisions": ["the base revision"], + }, "version": { "number": 3, "hash": "a7c2", @@ -844,7 +863,7 @@ mod tests { ); }; has("store 6d1e"); - has("the node"); + has("the node continuum:9c07 (beta)"); has(" lass's, voting for it by itself"); has("version 3 (a7c2)"); has(" 2 parties, 2 passing a change"); |
