diff options
| author | tv <tv@krebsco.de> | 2026-11-19 16:21:02 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-19 17:36:20 +0100 |
| commit | 602718835d034ef0a96c8ca29e47f06ce37008dc (patch) | |
| tree | 99a1ffbf50a4f59b3a5078dafa8c0cb3d192632c /src/api/events.rs | |
| parent | 9784111bd3b95be5352669b74e174920c101f349 (diff) | |
events: what moving to a proposed checkpoint refuses, shown
federation.md, and row 68, said a node shows, for a proposed checkpoint,
what it holds that its heads lack; no node did. `GET /events/counts`
now shows, of each proposal whose version names a checkpoint, the
writes, key sets and node lists the node took that moving there
refuses (`beside`; null for another version): neither among its heads,
in their history, nor above them, as the move has it, which their
parties sign again. Proposals and votes lapse with the move, and merge
events count for nothing: they are left out.
`Store::beside` finds them in one pass, as the move itself does: the
two share `Store::above`, which the move computed inline.
Diffstat (limited to 'src/api/events.rs')
| -rw-r--r-- | src/api/events.rs | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/api/events.rs b/src/api/events.rs index 5182c23..06a6e31 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -157,11 +157,12 @@ 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, what each of those nodes says it speaks and knows (`knows`), /// the values at places, the members, and the proposals on the -/// current version, each with the events proposing it a vote may build on (`proposing`: +/// current version, each with the events proposing it a vote may build on (`proposals`: /// for a checkpoint, those above its heads), the votes on it, the parties -/// voting `true` and `false`, whether it passed and whether it is dead, and why a party's +/// voting `true` and `false`, whether it passed and whether it is dead, why a party's /// client backs it not, where it is no version that can be written on the current one -/// (`client::backable`). +/// (`client::backable`), and, for a checkpoint, what its parties signed that moving there +/// refuses (`beside`, `signed_beside`). async fn counts(State(state): State<AppState>) -> Response { with_store(&state, |store| { let read = store.state(); @@ -196,6 +197,11 @@ async fn counts(State(state): State<AppState>) -> Response { .map(|(hash, ballot)| { let tally = read.tally(current, &hash); let proposing = read.proposing(¤t.hash, &hash); + let beside = read + .proposal(&hash) + .and_then(|json| crate::federation::version::Version::read(json).ok()) + .and_then(|version| version.checkpoint) + .map(|heads| ids(signed_beside(store, &heads))); let none = read .proposal(&hash) .and_then(|proposed| client::backable(current, proposed).err()) @@ -216,6 +222,7 @@ async fn counts(State(state): State<AppState>) -> Response { "passed": tally.passed, "dead": tally.dead, "none": none, + "beside": beside, }), ) }) @@ -239,6 +246,26 @@ async fn counts(State(state): State<AppState>) -> Response { }) } +/// Of what `store` took, what its parties signed that a move to a checkpoint at `heads` +/// refuses (`Store::beside`), and they sign again: their writes, key sets and node lists. +/// Proposals and votes lapse with the move, and merge events count for nothing. +fn signed_beside(store: &Store<Federation>, heads: &[Id]) -> Vec<Id> { + use crate::federation::event::{Does, Event, Signed}; + store + .beside(heads) + .into_iter() + .filter(|id| { + matches!( + store.get(id).and_then(Event::read_taken), + Some(Event::Signed(Signed { + does: Does::Write { .. } | Does::Keys(_) | Does::Nodes(_), + .. + })) + ) + }) + .collect() +} + /// What kind of refusal it is, as a client tells them apart, and the event it builds on, /// for one built on a refused one. fn kind(refusal: &Refusal) -> (&'static str, Option<&Id>) { |
