Skip to content

implemented /mempool endpoint, can now access mempool info such as the fee historgram #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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