From 77463c2b8b6535f6dfcfd244ec65f7f3900fd6d6 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 25 May 2017 14:20:58 +0800 Subject: [PATCH] tx_pool_size_kbytes added to api/networkinfo --- src/page.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/page.h b/src/page.h index 633818e..56e10df 100644 --- a/src/page.h +++ b/src/page.h @@ -402,8 +402,6 @@ namespace xmreg index2(uint64_t page_no = 0, bool refresh_page = false) { - - // we get network info, such as current hash rate // but since this makes a rpc call to deamon, we make it as an async // call. this way we dont have to wait with execution of the rest of the @@ -4825,6 +4823,26 @@ namespace xmreg j_info["fee_per_kb"] = fee_estimated; + // get mempool size in kB. + std::vector mempool_txs; + + if (!rpc.get_mempool(mempool_txs)) + { + j_response["status"] = "error"; + j_response["message"] = "Cant get mempool transactions"; + return j_response; + } + + uint64_t tx_pool_size_kbytes {0}; + + for (const tx_info& tx_i: mempool_txs) + { + tx_pool_size_kbytes += tx_i.blob_size; + } + + j_info["tx_pool_size"] = mempool_txs.size(); + j_info["tx_pool_size_kbytes"] = tx_pool_size_kbytes; + j_data = j_info; j_response["status"] = "success";