diff options
Diffstat (limited to 'src/api/events.rs')
| -rw-r--r-- | src/api/events.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/api/events.rs b/src/api/events.rs index 04dc77e..bd6db70 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -81,16 +81,21 @@ fn why(refusal: &Refusal) -> String { } /// `GET /events`: the store's ID, its checkpoint's, its heads, how many events it took -/// after its checkpoint, the node's party, and whether the node votes for it by itself. +/// after its checkpoint, the event it stopped at, if any, the node's party, and whether +/// the node votes for it by itself. async fn summary(State(state): State<AppState>) -> Response { let party = state.holding.party().map(str::to_owned); let votes = state.holding.votes_by_itself(); with_store(&state, |store| { + let stopped = store + .stopped() + .map(|(id, why, held)| json!({"id": id.to_string(), "why": why, "heldBack": held})); json!({ "store": store.id().to_string(), "checkpoint": Id::of(store.checkpoint()).to_string(), "heads": ids(store.heads()), "taken": store.taken().len(), + "stopped": stopped, "party": party, "votesByItself": votes, }) @@ -218,7 +223,7 @@ async fn refused(State(state): State<AppState>) -> Response { /// `POST /events`: puts an event, the request's body, whoever signed it: offered to the /// store, and written into the document at its ID unless the store refuses it. Taken, -/// held already, or waiting for what it builds on. +/// held already, waiting for what it builds on, or held back, the store stopped. async fn put( State(state): State<AppState>, Extension(AuthenticatedUser(user)): Extension<AuthenticatedUser>, @@ -238,6 +243,7 @@ async fn put( Some(Offered::Taken(_)) => "taken", Some(Offered::Held) => "held", Some(Offered::Waiting) => "waiting", + Some(Offered::Stopped) => "stopped", }; match crate::federation::held::write(&state, Some(user), bytes).await { Ok(()) => Json(json!({"id": id.to_string(), "event": became})).into_response(), @@ -359,10 +365,10 @@ async fn check_fork(State(state): State<AppState>, body: Bytes) -> Response { } } -/// `POST /admin/events/drop`: drops events the store took after its checkpoint, with -/// everything built on them, as the operator has the node do: it refuses them from then -/// on, from whoever brings them, and keeps so across restarts (`--store-file`). What it -/// dropped, in the order taken. +/// `POST /admin/events/drop`: drops events the store took after its checkpoint, or the +/// one it stopped at, with everything built on them, as the operator has the node do: it +/// refuses them from then on, from whoever brings them, and keeps so across restarts +/// (`--store-file`). What it dropped, in the order taken, then the one it stopped at. async fn drop_taken(State(state): State<AppState>, Json(named): Json<Named>) -> Response { let named = match named.ids() { Ok(ids) => ids, |
