Skip to content

Commit

Permalink
Merge #275: Add getmempoolinfo
Browse files Browse the repository at this point in the history
0f1c9f8 Add getmempoolinfo (dev7ba)

Pull request description:

  I've added getmempoolinfo to the client.

ACKs for top commit:
  apoelstra:
    ACK 0f1c9f8

Tree-SHA512: 787b43a705b221d8f48e4313e682d5c0f7255ddf9d0cdf204811341c3d5117d9b3740faa43dc3abad3d6fc47efc3f772d48e2be340bfaaeb070f7566c25dfb36
  • Loading branch information
apoelstra committed Jan 30, 2023
2 parents 7e141b6 + 0f1c9f8 commit b469e3f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,11 @@ pub trait RpcApi: Sized {
self.call("reconsiderblock", &[into_json(block_hash)?])
}

/// Returns details on the active state of the TX memory pool
fn get_mempool_info(&self) -> Result<json::GetMempoolInfoResult> {
self.call("getmempoolinfo", &[])
}

/// Get txids of all transactions in a memory pool
fn get_raw_mempool(&self) -> Result<Vec<bitcoin::Txid>> {
self.call("getrawmempool", &[])
Expand Down
33 changes: 33 additions & 0 deletions json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,39 @@ pub enum ImportMultiRequestScriptPubkey<'a> {
Script(&'a Script),
}

#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
pub struct GetMempoolInfoResult {
/// True if the mempool is fully loaded
pub loaded: bool,
/// Current tx count
pub size: usize,
/// Sum of all virtual transaction sizes as defined in BIP 141. Differs from actual serialized size because witness data is discounted
pub bytes: usize,
/// Total memory usage for the mempool
pub usage: usize,
/// Total fees for the mempool in BTC, ignoring modified fees through prioritisetransaction
#[serde(with = "bitcoin::util::amount::serde::as_btc")]
pub total_fee: Amount,
/// Maximum memory usage for the mempool
#[serde(rename = "maxmempool")]
pub max_mempool: usize,
/// Minimum fee rate in BTC/kvB for tx to be accepted. Is the maximum of minrelaytxfee and minimum mempool fee
#[serde(rename = "mempoolminfee", with = "bitcoin::util::amount::serde::as_btc")]
pub mempool_min_fee: Amount,
/// Current minimum relay fee for transactions
#[serde(rename = "minrelaytxfee", with = "bitcoin::util::amount::serde::as_btc")]
pub min_relay_tx_fee: Amount,
/// Minimum fee rate increment for mempool limiting or replacement in BTC/kvB
#[serde(rename = "incrementalrelayfee", with = "bitcoin::util::amount::serde::as_btc")]
pub incremental_relay_fee: Amount,
/// Current number of transactions that haven't passed initial broadcast yet
#[serde(rename = "unbroadcastcount")]
pub unbroadcast_count: usize,
/// True if the mempool accepts RBF without replaceability signaling inspection
#[serde(rename = "fullrbf")]
pub full_rbf: bool,
}

#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
pub struct GetMempoolEntryResult {
/// Virtual transaction size as defined in BIP 141. This is different from actual serialized
Expand Down

0 comments on commit b469e3f

Please sign in to comment.