diff options
| author | tv <tv@krebsco.de> | 2026-11-16 21:45:11 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-16 23:07:29 +0100 |
| commit | 0c213626ba238fd6d8d69d08475d57e486f6f27a (patch) | |
| tree | cee091c61ef3fd9505a04eaadba482785f422a1e /src/api | |
| parent | d893a092c469688eaf98c98725fedf6dfad99614 (diff) | |
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`).
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/events.rs | 14 |
1 files changed, 13 insertions, 1 deletions
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<AppState>, Path(id): Path<String>) -> 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<AppState>) -> Response { with_store(&state, |store| { let read = store.state(); @@ -131,6 +132,16 @@ async fn counts(State(state): State<AppState>) -> Response { .iter() .map(|(path, value)| (path.clone(), plain(value))) .collect(); + let proposals: serde_json::Map<String, JsonValue> = 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<AppState>) -> Response { "parties": parties, "values": values, "members": read.members(), + "proposals": proposals, }) }) } |
