aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 21:46:03 +0000
committertv <tv@krebsco.de>2026-11-16 23:07:38 +0100
commit491751e51a554d991d5066dbe968aa44f3d66f30 (patch)
tree4840b910e8cec8014c7ce949e1f68d0c49a622ab
parent0c213626ba238fd6d8d69d08475d57e486f6f27a (diff)
api: what the store refused, by kind
`GET /events/refused` says of each refusal its kind (`none`, `judged`, `builtOn`, with the event it builds on, or `notAbove`), apart from why: a party's client signs again what a move refused, which it tells so.
-rw-r--r--docs/openapi.yaml11
-rw-r--r--src/api/events.rs24
2 files changed, 31 insertions, 4 deletions
diff --git a/docs/openapi.yaml b/docs/openapi.yaml
index c8f839c..1bb69e3 100644
--- a/docs/openapi.yaml
+++ b/docs/openapi.yaml
@@ -1555,7 +1555,9 @@ paths:
The events the store refused: `own`, those its history takes but this node
doesn't, by what it took before (a version changing another than the one it
reads), apart from the rest; `dropped`, those its operator had it drop; and
- `refused`, every other, with why.
+ `refused`, every other, with its kind (`none`: none of the federation's events;
+ `judged`: refused at its history; `builtOn`: built on `on`, refused;
+ `notAbove`: not above the checkpoint's heads, as a move refuses it) and why.
responses:
'200':
description: What it refused.
@@ -1577,10 +1579,15 @@ paths:
type: array
items:
type: object
- required: [id, why]
+ required: [id, kind, why]
properties:
id:
type: string
+ kind:
+ type: string
+ enum: [none, judged, builtOn, notAbove]
+ on:
+ type: string
why:
type: string
'404':
diff --git a/src/api/events.rs b/src/api/events.rs
index 2fa6719..65c6238 100644
--- a/src/api/events.rs
+++ b/src/api/events.rs
@@ -156,9 +156,22 @@ async fn counts(State(state): State<AppState>) -> Response {
})
}
+/// 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>) {
+ match refusal {
+ Refusal::None => ("none", None),
+ Refusal::Judged(_) => ("judged", None),
+ Refusal::BuiltOn(id) => ("builtOn", Some(id)),
+ Refusal::NotAbove => ("notAbove", None),
+ Refusal::Own => ("own", None),
+ Refusal::Dropped => ("dropped", None),
+ }
+}
+
/// `GET /events/refused`: what the store refused: of its own, by what it took before (the
/// federation: a version changing another than the one it reads), apart; what its
-/// operator had it drop; and the rest, each with why.
+/// operator had it drop; and the rest, each with its kind and why.
async fn refused(State(state): State<AppState>) -> Response {
with_store(&state, |store| {
let (own, dropped) = store.own();
@@ -172,7 +185,14 @@ async fn refused(State(state): State<AppState>) -> Response {
"dropped": ids(dropped),
"refused": rest
.into_iter()
- .map(|(id, refusal)| json!({"id": id.to_string(), "why": why(refusal)}))
+ .map(|(id, refusal)| {
+ let (kind, on) = kind(refusal);
+ let mut entry = json!({"id": id.to_string(), "kind": kind, "why": why(refusal)});
+ if let Some(on) = on {
+ entry["on"] = json!(on.to_string());
+ }
+ entry
+ })
.collect::<Vec<_>>(),
})
})