From 0c213626ba238fd6d8d69d08475d57e486f6f27a Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 21:45:11 +0000 Subject: api: what counts names the proposals on the current version, and their votes A party's client votes by the record it keeps, and keeps the votes that made its party's earlier proposal dead; it reads them from a node, and checks them itself, as each is signed. `GET /events/counts` names the proposals on the current version, by their hash, each with the events proposing it and the votes on it, by ID (`State::ballots`). --- src/api/events.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/api') diff --git a/src/api/events.rs b/src/api/events.rs index 3291f02..2fa6719 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -108,7 +108,8 @@ async fn event(State(state): State, Path(id): Path) -> Respons } /// `GET /events/counts`: what counts, as the store reads now: the current version, each -/// party's keys and nodes, the values at places, and the members. +/// party's keys and nodes, the values at places, the members, and the proposals on the +/// current version, each with the events proposing it and the votes on it. async fn counts(State(state): State) -> Response { with_store(&state, |store| { let read = store.state(); @@ -131,6 +132,16 @@ async fn counts(State(state): State) -> Response { .iter() .map(|(path, value)| (path.clone(), plain(value))) .collect(); + let proposals: serde_json::Map = read + .ballots(¤t.hash) + .into_iter() + .map(|(hash, ballot)| { + ( + hash.to_string(), + json!({"proposals": ids(ballot.proposals), "votes": ids(ballot.votes)}), + ) + }) + .collect(); json!({ "version": { "number": current.number, @@ -140,6 +151,7 @@ async fn counts(State(state): State) -> Response { "parties": parties, "values": values, "members": read.members(), + "proposals": proposals, }) }) } -- cgit v1.3.1