Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ pub struct AddressTxsSummary {
pub tx_count: u32,
}

#[derive(Deserialize, Clone, Debug, PartialEq)]
pub struct MempoolInfo {
pub count: u32,
pub vsize: u64,
pub total_fee: u64,
pub fee_histogram: Vec<(f32, u64)>,
}

impl Tx {
pub fn to_tx(&self) -> Transaction {
Transaction {
Expand Down
6 changes: 5 additions & 1 deletion src/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use log::{debug, error, info, trace};

use reqwest::{header, Client, Response};

use crate::api::AddressStats;
use crate::api::{AddressStats, MempoolInfo};
use crate::{
BlockStatus, BlockSummary, Builder, Error, MerkleProof, OutputStatus, Tx, TxStatus,
BASE_BACKOFF_MILLIS, RETRYABLE_ERROR_CODES,
Expand Down Expand Up @@ -432,6 +432,10 @@ impl<S: Sleeper> AsyncClient<S> {
self.get_response_json("/fee-estimates").await
}

pub async fn get_mempool_info(&self) -> Result<MempoolInfo, Error> {
self.get_response_json("/mempool").await
}

/// Gets some recent block summaries starting at the tip or at `height` if
/// provided.
///
Expand Down
6 changes: 5 additions & 1 deletion src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use bitcoin::{
block::Header as BlockHeader, Block, BlockHash, MerkleBlock, Script, Transaction, Txid,
};

use crate::api::AddressStats;
use crate::api::{AddressStats, MempoolInfo};
use crate::{
BlockStatus, BlockSummary, Builder, Error, MerkleProof, OutputStatus, Tx, TxStatus,
BASE_BACKOFF_MILLIS, RETRYABLE_ERROR_CODES,
Expand Down Expand Up @@ -319,6 +319,10 @@ impl BlockingClient {
self.get_response_json("/fee-estimates")
}

pub fn get_mempool_info(&self) -> Result<MempoolInfo, Error> {
self.get_response_json("/mempool")
}

/// Get information about a specific address, includes confirmed balance and transactions in
/// the mempool.
pub fn get_address_stats(&self, address: &Address) -> Result<AddressStats, Error> {
Expand Down
Loading