From 1ed4ccdb0cd3a9407b6101b1bc595df2a451a18d Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 16:10:34 +0000 Subject: 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. --- src/api/events.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/api/events.rs') 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, 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, 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) -> Response { with_store(&state, |store| { let read = store.state(); @@ -138,9 +139,17 @@ async fn counts(State(state): State) -> 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(); -- cgit v1.3.1