diff options
| author | tv <tv@krebsco.de> | 2026-11-17 16:10:34 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-17 17:14:22 +0100 |
| commit | 1ed4ccdb0cd3a9407b6101b1bc595df2a451a18d (patch) | |
| tree | d75459a0844e3be3d9f646af66fe0ab60586b526 /src/api/events.rs | |
| parent | 2f78f51a4cd779e0ab989057727995f7bccf75ab (diff) | |
events: counts names who voted what, and whether a proposal passed or is dead
`GET /events/counts` gives each proposal on the current version the parties voting
`true` and `false` (`yes`, `no`), whether it passed and whether it is dead (`passed`,
`dead`), as the node reads its votes (`State::tally`, which the fold judges by too), so
that reading where a vote stands takes no fetch of every vote. A party's client still
decides its votes by the votes it checks itself.
Diffstat (limited to 'src/api/events.rs')
| -rw-r--r-- | src/api/events.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/api/events.rs b/src/api/events.rs index 9fa8786..b388acc 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -111,7 +111,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, the members, and the proposals on the -/// current version, each with the events proposing it and the votes on it. +/// current version, each with the events proposing it, the votes on it, the parties +/// voting `true` and `false`, and whether it passed and whether it is dead. async fn counts(State(state): State<AppState>) -> Response { with_store(&state, |store| { let read = store.state(); @@ -138,9 +139,17 @@ async fn counts(State(state): State<AppState>) -> Response { .ballots(¤t.hash) .into_iter() .map(|(hash, ballot)| { + let tally = read.tally(current, &hash); ( hash.to_string(), - json!({"proposals": ids(ballot.proposals), "votes": ids(ballot.votes)}), + json!({ + "proposals": ids(ballot.proposals), + "votes": ids(ballot.votes), + "yes": tally.yes, + "no": tally.no, + "passed": tally.passed, + "dead": tally.dead, + }), ) }) .collect(); |
