aboutsummaryrefslogtreecommitdiff
path: root/src/rpcblockchain.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2014-08-06 23:58:19 -0400
committerJeff Garzik <jgarzik@bitpay.com>2014-08-14 12:34:38 -0400
commit6f2c26a457d279138d23d0f321edf55cd6b1f72f (patch)
treece209c55c8ede839f538481135bf6949523db5cc /src/rpcblockchain.cpp
parent7accb7dbad6bef0c98dc436d164f27189294eaf5 (diff)
downloadbitcoin-6f2c26a457d279138d23d0f321edf55cd6b1f72f.tar.xz
Closely track mempool byte total. Add "getmempoolinfo" RPC.
Goal: Gain live insight into the mempool. Groundwork for future work that caps mempool size.
Diffstat (limited to 'src/rpcblockchain.cpp')
-rw-r--r--src/rpcblockchain.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index 1e5198b85c..e511fe4222 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -531,3 +531,27 @@ Value getchaintips(const Array& params, bool fHelp)
return res;
}
+
+Value getmempoolinfo(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 0)
+ throw runtime_error(
+ "getmempoolinfo\n"
+ "\nReturns details on the active state of the TX memory pool.\n"
+ "\nResult:\n"
+ "{\n"
+ " \"size\": xxxxx (numeric) Current tx count\n"
+ " \"bytes\": xxxxx (numeric) Sum of all tx sizes\n"
+ "}\n"
+ "\nExamples:\n"
+ + HelpExampleCli("getmempoolinfo", "")
+ + HelpExampleRpc("getmempoolinfo", "")
+ );
+
+ Object ret;
+ ret.push_back(Pair("size", (int64_t) mempool.size()));
+ ret.push_back(Pair("bytes", (int64_t) mempool.GetTotalTxSize()));
+
+ return ret;
+}
+