aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/party
diff options
context:
space:
mode:
Diffstat (limited to 'src/federation/party')
-rw-r--r--src/federation/party/status.rs37
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");