diff --git a/committer/src/api.rs b/committer/src/api.rs index 20e3fc15..6eca6ee2 100644 --- a/committer/src/api.rs +++ b/committer/src/api.rs @@ -94,12 +94,13 @@ async fn metrics(registry: web::Data>) -> impl Responder { #[serde(rename_all = "lowercase")] enum HeightVariant { Latest, - Height(u32), + Specific, } #[derive(Deserialize)] struct CostQueryParams { variant: HeightVariant, + value: Option, limit: Option, } @@ -112,7 +113,12 @@ async fn costs( let response = match query.variant { HeightVariant::Latest => data.get_latest_costs(limit).await, - HeightVariant::Height(from_height) => data.get_costs(from_height, limit).await, + HeightVariant::Specific => { + let from_height = query + .value + .ok_or_else(|| services::Error::Other("height value is required".to_string()))?; + data.get_costs(from_height, limit).await + } }; match response {