global: fixes

This commit is contained in:
nym21
2026-05-01 19:14:15 +02:00
parent 1068ad4e8f
commit 6f879a5551
36 changed files with 949 additions and 337 deletions
+7 -6
View File
@@ -5,7 +5,8 @@ use axum::{
};
use brk_query::BLOCK_TXS_PAGE_SIZE;
use brk_types::{
BlockInfo, BlockInfoV1, BlockStatus, BlockTimestamp, Transaction, TxIndex, Txid, Version,
BlockHash, BlockInfo, BlockInfoV1, BlockStatus, BlockTimestamp, Height, Hex, Transaction,
TxIndex, Txid, Version,
};
use crate::{
@@ -82,7 +83,7 @@ impl BlockRoutes for ApiRouter<AppState> {
.blocks_tag()
.summary("Block header")
.description("Returns the hex-encoded 80-byte block header.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-header)*")
.text_response()
.text_response::<Hex>()
.not_modified()
.bad_request()
.not_found()
@@ -106,7 +107,7 @@ impl BlockRoutes for ApiRouter<AppState> {
.description(
"Retrieve the block hash at a given height. Returns the hash as plain text.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-height)*",
)
.text_response()
.text_response::<BlockHash>()
.not_modified()
.bad_request()
.not_found()
@@ -196,7 +197,7 @@ impl BlockRoutes for ApiRouter<AppState> {
.blocks_tag()
.summary("Block tip height")
.description("Returns the height of the last block.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-tip-height)*")
.text_response()
.text_response::<Height>()
.not_modified()
.server_error()
},
@@ -213,7 +214,7 @@ impl BlockRoutes for ApiRouter<AppState> {
.blocks_tag()
.summary("Block tip hash")
.description("Returns the hash of the last block.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-tip-hash)*")
.text_response()
.text_response::<BlockHash>()
.not_modified()
.server_error()
},
@@ -236,7 +237,7 @@ impl BlockRoutes for ApiRouter<AppState> {
.description(
"Retrieve a single transaction ID at a specific index within a block. Returns plain text txid.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-transaction-id)*",
)
.text_response()
.text_response::<Txid>()
.not_modified()
.bad_request()
.not_found()
+43 -1
View File
@@ -3,7 +3,7 @@ use axum::{
extract::State,
http::{HeaderMap, Uri},
};
use brk_types::{Dollars, MempoolInfo, MempoolRecentTx, Txid};
use brk_types::{Dollars, MempoolInfo, MempoolRecentTx, ReplacementNode, Txid};
use crate::{AppState, extended::TransformResponseExtended, params::Empty};
@@ -70,6 +70,48 @@ impl MempoolRoutes for ApiRouter<AppState> {
},
),
)
.api_route(
"/api/v1/replacements",
get_with(
async |uri: Uri, headers: HeaderMap, _: Empty, State(state): State<AppState>| {
state
.respond_json(&headers, state.mempool_strategy(), &uri, |q| {
q.recent_replacements(false)
})
.await
},
|op| {
op.id("get_replacements")
.mempool_tag()
.summary("Recent RBF replacements")
.description("Returns up to 25 most-recent RBF replacement trees across the whole mempool. Each entry has the same shape as `tx_rbf().replacements`.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-replacements)*")
.json_response::<Vec<ReplacementNode>>()
.not_modified()
.server_error()
},
),
)
.api_route(
"/api/v1/fullrbf/replacements",
get_with(
async |uri: Uri, headers: HeaderMap, _: Empty, State(state): State<AppState>| {
state
.respond_json(&headers, state.mempool_strategy(), &uri, |q| {
q.recent_replacements(true)
})
.await
},
|op| {
op.id("get_fullrbf_replacements")
.mempool_tag()
.summary("Recent full-RBF replacements")
.description("Like `/api/v1/replacements`, but limited to trees where at least one predecessor was non-signaling (full-RBF).\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-fullrbf-replacements)*")
.json_response::<Vec<ReplacementNode>>()
.not_modified()
.server_error()
},
),
)
.api_route(
"/api/mempool/price",
get_with(
+2 -2
View File
@@ -34,7 +34,7 @@ impl ServerRoutes for ApiRouter<AppState> {
.client()
.get_last_height()
.unwrap_or(q.indexed_height());
Ok(q.sync_status(tip_height))
q.sync_status(tip_height)
})
.await
.expect("health sync task panicked");
@@ -89,7 +89,7 @@ impl ServerRoutes for ApiRouter<AppState> {
state
.respond_json(&headers, CacheStrategy::Tip, &uri, move |q| {
let tip_height = q.client().get_last_height()?;
Ok(q.sync_status(tip_height))
q.sync_status(tip_height)
})
.await
},
+5 -7
View File
@@ -8,7 +8,7 @@ use axum::{
response::Response,
};
use brk_types::{
CpfpInfo, MerkleProof, RbfResponse, Transaction, TxOutspend, TxStatus, Txid, Version,
CpfpInfo, Hex, MerkleProof, RbfResponse, Transaction, TxOutspend, TxStatus, Txid, Version,
};
use crate::{
@@ -35,7 +35,7 @@ impl TxRoutes for ApiRouter<AppState> {
.transactions_tag()
.summary("Txid by index")
.description("Retrieve the transaction ID (txid) at a given global transaction index. Returns the txid as plain text.")
.text_response()
.text_response::<Txid>()
.not_modified()
.bad_request()
.not_found()
@@ -123,7 +123,7 @@ impl TxRoutes for ApiRouter<AppState> {
.description(
"Retrieve the raw transaction as a hex-encoded string. Returns the serialized transaction in hexadecimal format.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-transaction-hex)*",
)
.text_response()
.text_response::<Hex>()
.not_modified()
.bad_request()
.not_found()
@@ -141,7 +141,7 @@ impl TxRoutes for ApiRouter<AppState> {
.transactions_tag()
.summary("Transaction merkleblock proof")
.description("Get the merkleblock proof for a transaction (BIP37 format, hex encoded).\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-transaction-merkleblock-proof)*")
.text_response()
.text_response::<Hex>()
.not_modified()
.bad_request()
.not_found()
@@ -281,9 +281,7 @@ impl TxRoutes for ApiRouter<AppState> {
.api_route(
"/api/v1/transaction-times",
get_with(
async |uri: Uri, headers: HeaderMap, State(state): State<AppState>| -> Result<Response> {
let params = TxidsParam::from_query(uri.query().unwrap_or(""))
.map_err(Error::bad_request)?;
async |uri: Uri, headers: HeaderMap, params: TxidsParam, State(state): State<AppState>| -> Result<Response> {
Ok(state.respond_json(&headers, state.mempool_strategy(), &uri, move |q| q.transaction_times(&params.txids)).await)
},
|op| op