aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/openapi.yaml8
-rw-r--r--src/api/events.rs6
-rw-r--r--src/federation/party/status.rs32
3 files changed, 32 insertions, 14 deletions
diff --git a/docs/openapi.yaml b/docs/openapi.yaml
index 8dfbc88..adc5426 100644
--- a/docs/openapi.yaml
+++ b/docs/openapi.yaml
@@ -1459,7 +1459,7 @@ paths:
stopped at, if any (`stopped`: a version event writing a version that passed,
which this continuum doesn't read), why, and how many events it holds back since,
that one among them, taking nothing and refusing nothing until upgraded or told to
- drop it (`/admin/events/drop`); the party this node is of (`party`,
+ drop it (`/admin/events/drop`); this node's ID (`node`); the party it is of (`party`,
`--store-party`), and whether it votes for it by itself (`votesByItself`), and so
casts votes by hand (`POST /admin/events/vote`); and the revisions of the
federation this continuum knows (`revisions`), the base revision first, each its
@@ -1473,8 +1473,8 @@ paths:
application/json:
schema:
type: object
- required: [store, checkpoint, heads, taken, stopped, party, votesByItself,
- revisions]
+ required: [store, checkpoint, heads, taken, stopped, node, party,
+ votesByItself, revisions]
properties:
store:
type: string
@@ -1496,6 +1496,8 @@ paths:
type: string
heldBack:
type: integer
+ node:
+ type: string
party:
type: [string, 'null']
votesByItself:
diff --git a/src/api/events.rs b/src/api/events.rs
index d6c06c4..5a69769 100644
--- a/src/api/events.rs
+++ b/src/api/events.rs
@@ -84,8 +84,9 @@ fn why(refusal: &Refusal) -> String {
/// `GET /events`: the store's ID, its checkpoint's, its heads, as many as an event may
/// name, what a new event builds on (`Store::building_on`), how many events it took
-/// after its checkpoint, the event it stopped at, if any, the node's party, whether the
-/// node votes for it by itself, and the revisions of the federation its continuum knows.
+/// after its checkpoint, the event it stopped at, if any, the node's ID and party, whether
+/// the node votes for it by itself, and the revisions of the federation its continuum
+/// knows.
async fn summary(State(state): State<AppState>) -> Response {
let party = state.holding.party().map(str::to_owned);
let votes = state.holding.votes_by_itself();
@@ -99,6 +100,7 @@ async fn summary(State(state): State<AppState>) -> Response {
"heads": ids(store.building_on()),
"taken": store.taken().len(),
"stopped": stopped,
+ "node": state.local_id(),
"party": party,
"votesByItself": votes,
"revisions": revisions(),
diff --git a/src/federation/party/status.rs b/src/federation/party/status.rs
index 2428845..4c637fa 100644
--- a/src/federation/party/status.rs
+++ b/src/federation/party/status.rs
@@ -66,6 +66,7 @@ async fn model(node: &Node, options: &Options, party: Option<&str>) -> Result<Js
json!({
"id": id,
"name": of["names"][id],
+ "here": summary["node"].as_str() == Some(id.as_str()),
"heard": of["heard"][id],
"knows": of["knows"][id],
})
@@ -112,6 +113,7 @@ async fn model(node: &Node, options: &Options, party: Option<&str>) -> Result<Js
"stopped": summary["stopped"],
},
"node": {
+ "id": summary["node"],
"party": summary["party"],
"votesByItself": summary["votesByItself"],
"revisions": revisions,
@@ -528,7 +530,7 @@ fn render(model: &JsonValue, paint: &Paint) -> Vec<String> {
paint.paint(Style::Id, &text(&node["id"]))
));
let heard = match node["heard"].as_u64() {
- Some(0) => paint.paint(Style::Good, "this node"),
+ _ if node["here"].as_bool() == Some(true) => paint.paint(Style::Good, "this node"),
Some(seconds) if seconds <= LATELY => {
paint.paint(Style::Good, &format!("heard {}", ago(seconds)))
}
@@ -770,19 +772,29 @@ mod tests {
"lass": {
"keys": ["ssh-ed25519 AAAAone"],
"keySet": ["ssh-ed25519 AAAAone"],
- "nodes": [{
- "id": "continuum:9c07",
- "name": "beta",
- "heard": 0,
- "knows": {"wire": [52, 52], "revision": {"named": "the base revision"}},
- }],
+ "nodes": [
+ {
+ "id": "continuum:9c07",
+ "name": "beta",
+ "here": true,
+ "heard": 0,
+ "knows": {"wire": [52, 52], "revision": {"named": "the base revision"}},
+ },
+ {
+ "id": "continuum:3b1e",
+ "name": null,
+ "here": false,
+ "heard": 0,
+ "knows": {"wire": [52, 52], "revision": null},
+ },
+ ],
},
"tv": {
"keys": ["ssh-ed25519 AAAAtwo"],
"keySet": ["ssh-ed25519 AAAAthree"],
"nodes": [
- {"id": "continuum:5be1", "name": null, "heard": LATELY + 1, "knows": null},
- {"id": "continuum:77d0", "name": null, "heard": null, "knows": null},
+ {"id": "continuum:5be1", "name": null, "here": false, "heard": LATELY + 1, "knows": null},
+ {"id": "continuum:77d0", "name": null, "here": false, "heard": null, "knows": null},
],
},
},
@@ -839,6 +851,8 @@ mod tests {
has(" tv");
has(" continuum:9c07 (beta)");
has(" this node; wire 52; the base revision");
+ // Another node heard from within the second is no less another.
+ has(" heard 0 s ago; wire 52; no federation");
has(&format!(
" heard {}; said nothing of what it runs",
ago(LATELY + 1)