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
+7 -5
View File
@@ -7,7 +7,7 @@ use brk_monitor::Mempool;
use brk_reader::Reader;
use brk_types::{
Address, AddressStats, BlockInfo, BlockStatus, Height, Index, IndexInfo, Limit, MempoolInfo,
Metric, MetricCount, Transaction, TreeNode, TxStatus, Txid, TxidPath, Utxo,
Metric, MetricCount, RecommendedFees, Transaction, TreeNode, TxStatus, Txid, TxidPath, Utxo,
};
use tokio::task::spawn_blocking;
@@ -98,13 +98,15 @@ impl AsyncQuery {
}
pub async fn get_mempool_info(&self) -> Result<MempoolInfo> {
let query = self.0.clone();
spawn_blocking(move || query.get_mempool_info()).await?
self.0.get_mempool_info()
}
pub async fn get_mempool_txids(&self) -> Result<Vec<Txid>> {
let query = self.0.clone();
spawn_blocking(move || query.get_mempool_txids()).await?
self.0.get_mempool_txids()
}
pub async fn get_recommended_fees(&self) -> Result<RecommendedFees> {
self.0.get_recommended_fees()
}
pub async fn match_metric(&self, metric: Metric, limit: Limit) -> Result<Vec<&'static str>> {
@@ -0,0 +1,11 @@
use brk_error::{Error, Result};
use brk_types::RecommendedFees;
use crate::Query;
pub fn get_recommended_fees(query: &Query) -> Result<RecommendedFees> {
query
.mempool()
.map(|mempool| mempool.get_fees())
.ok_or(Error::MempoolNotAvailable)
}
@@ -1,5 +1,7 @@
mod fees;
mod info;
mod txids;
pub use fees::*;
pub use info::*;
pub use txids::*;
+7 -3
View File
@@ -11,7 +11,7 @@ use brk_reader::Reader;
use brk_traversable::TreeNode;
use brk_types::{
Address, AddressStats, BlockInfo, BlockStatus, Format, Height, Index, IndexInfo, Limit,
MempoolInfo, Metric, MetricCount, Transaction, TxStatus, Txid, TxidPath, Utxo,
MempoolInfo, Metric, MetricCount, RecommendedFees, Transaction, TxStatus, Txid, TxidPath, Utxo,
};
use vecdb::{AnyExportableVec, AnyStoredVec};
@@ -35,8 +35,8 @@ use crate::{
chain::{
get_address, get_address_txids, get_address_utxos, get_block_by_height,
get_block_status_by_height, get_block_txids, get_blocks, get_height_by_hash,
get_mempool_info, get_mempool_txids, get_transaction, get_transaction_hex,
get_transaction_status,
get_mempool_info, get_mempool_txids, get_recommended_fees, get_transaction,
get_transaction_hex, get_transaction_status,
},
vecs::{IndexToVec, MetricToVec},
};
@@ -136,6 +136,10 @@ impl Query {
get_mempool_txids(self)
}
pub fn get_recommended_fees(&self) -> Result<RecommendedFees> {
get_recommended_fees(self)
}
pub fn match_metric(&self, metric: &Metric, limit: Limit) -> Vec<&'static str> {
self.vecs().matches(metric, limit)
}