bitcoind_request/command/
get_mempool_info.rs

1/*
2getmempoolinfo
3
4Returns details on the active state of the TX memory pool.
5
6Result:
7{                            (json object)
8  "loaded" : true|false,     (boolean) True if the mempool is fully loaded
9  "size" : n,                (numeric) Current tx count
10  "bytes" : n,               (numeric) Sum of all virtual transaction sizes as defined in BIP 141. Differs from actual serialized size because witness data is discounted
11  "usage" : n,               (numeric) Total memory usage for the mempool
12  "total_fee" : n,           (numeric) Total fees for the mempool in BTC, ignoring modified fees through prioritizetransaction
13  "maxmempool" : n,          (numeric) Maximum memory usage for the mempool
14  "mempoolminfee" : n,       (numeric) Minimum fee rate in BTC/kvB for tx to be accepted. Is the maximum of minrelaytxfee and minimum mempool fee
15  "minrelaytxfee" : n,       (numeric) Current minimum relay fee for transactions
16  "unbroadcastcount" : n     (numeric) Current number of transactions that haven't passed initial broadcast yet
17}
18
19Examples:
20> bitcoin-cli getmempoolinfo
21> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getmempoolinfo", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
22*/
23use crate::client::Client;
24use crate::command::request::request;
25use crate::command::CallableCommand;
26use serde::Deserialize;
27use serde::Serialize;
28use serde_json::value::RawValue;
29
30pub struct GetMempoolInfoCommand {}
31impl GetMempoolInfoCommand {
32    pub fn new() -> Self {
33        GetMempoolInfoCommand {}
34    }
35}
36
37#[derive(Serialize, Deserialize, Debug)]
38pub struct GetMempoolInfoCommandResponse {
39    loaded: bool,
40    size: u64,
41    bytes: u64,
42    usage: u64,
43    total_fee: f64,
44    maxmempool: u64,
45    mempoolminfee: f64,
46    minrelaytxfee: f64,
47    unbroadcastcount: u64,
48}
49
50impl CallableCommand for GetMempoolInfoCommand {
51    type Response = GetMempoolInfoCommandResponse;
52    fn call(&self, client: &Client) -> Result<Self::Response, jsonrpc::Error> {
53        let command = "getmempoolinfo";
54        let params: Vec<Box<RawValue>> = vec![];
55        let r = request(client, command, params);
56        let response: GetMempoolInfoCommandResponse = r.result()?;
57        Ok(response)
58    }
59}