mempool: snapshot

This commit is contained in:
nym21
2025-12-13 11:10:11 +01:00
parent 158b0254ed
commit 9c8b9b1a3b
12 changed files with 333 additions and 174 deletions

View File

@@ -5,7 +5,7 @@ use axum::{
response::{Redirect, Response},
routing::get,
};
use brk_types::{MempoolInfo, Txid};
use brk_types::{MempoolInfo, RecommendedFees, Txid};
use crate::{
VERSION,
@@ -62,5 +62,25 @@ impl MempoolRoutes for ApiRouter<AppState> {
},
),
)
.api_route(
"/api/v1/fees/recommended",
get_with(
async |headers: HeaderMap, State(state): State<AppState>| {
let etag = format!("{VERSION}-{}", state.get_height().await);
if headers.has_etag(&etag) {
return Response::new_not_modified();
}
state.get_recommended_fees().await.to_json_response(&etag)
},
|op| {
op.mempool_tag()
.summary("Recommended fees")
.description("Get recommended fee rates for different confirmation targets based on current mempool state.")
.ok_response::<RecommendedFees>()
.not_modified()
.server_error()
},
),
)
}
}