mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-19 06:14:47 -07:00
mempool: general improvements
This commit is contained in:
@@ -159,8 +159,10 @@ impl ClientInner {
|
||||
}
|
||||
|
||||
/// Like `call_batch` but reports per-request success/failure independently,
|
||||
/// so one bad item doesn't nuke an otherwise-healthy chunk. The outer
|
||||
/// `Result` still fails if the HTTP round-trip itself fails.
|
||||
/// so one bad item doesn't nuke an otherwise-healthy chunk. Per-item
|
||||
/// failures preserve the underlying `JsonRpcError` so the caller can
|
||||
/// pattern-match on the RPC error code. The outer `Result` still fails
|
||||
/// if the HTTP round-trip itself fails.
|
||||
pub(crate) fn call_batch_per_item<T>(
|
||||
&self,
|
||||
method: &str,
|
||||
@@ -188,8 +190,7 @@ impl ClientInner {
|
||||
.into_iter()
|
||||
.map(|resp| {
|
||||
let resp = resp.ok_or(Error::Internal("Missing response in JSON-RPC batch"))?;
|
||||
resp.result::<T>()
|
||||
.map_err(|e| Error::Parse(format!("batch {method} result: {e}")))
|
||||
resp.result::<T>().map_err(Error::from)
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::{thread::sleep, time::Duration};
|
||||
use bitcoin::{consensus::encode, hex::FromHex};
|
||||
use brk_error::{Error, Result};
|
||||
use brk_types::{Bitcoin, BlockHash, FeeRate, Height, MempoolEntryInfo, Sats, Txid, Vout};
|
||||
use corepc_jsonrpc::error::Error as JsonRpcError;
|
||||
use corepc_types::v30::{
|
||||
GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderVerbose, GetBlockVerboseOne,
|
||||
GetBlockVerboseZero, GetBlockchainInfo, GetMempoolInfo, GetRawMempool, GetRawMempoolVerbose,
|
||||
@@ -13,6 +14,11 @@ use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
use tracing::{debug, info};
|
||||
|
||||
/// Bitcoin Core's `-5` (`RPC_INVALID_ADDRESS_OR_KEY`) is the expected
|
||||
/// response when querying a confirmed transaction without `-txindex`.
|
||||
/// The mempool fetcher tolerates these per-item failures silently.
|
||||
const RPC_NOT_FOUND: i32 = -5;
|
||||
|
||||
use crate::{
|
||||
BlockHeaderInfo, BlockInfo, BlockTemplateTx, BlockchainInfo, Client, RawTx, TxOutInfo,
|
||||
};
|
||||
@@ -289,9 +295,8 @@ impl Client {
|
||||
Ok(raw) => {
|
||||
out.insert(txid.clone(), raw);
|
||||
}
|
||||
// Silenced: users without `-txindex` expect -5 for
|
||||
// every confirmed tx. Downgraded so the mempool
|
||||
// parent-fetch loop doesn't spam the log each cycle.
|
||||
Err(Error::CorepcRPC(JsonRpcError::Rpc(rpc)))
|
||||
if rpc.code == RPC_NOT_FOUND => {}
|
||||
Err(e) => {
|
||||
debug!(txid = %txid, error = %e, "getrawtransaction batch: item failed")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user