total size of mempool in kB added

This commit is contained in:
moneroexamples 2017-01-17 00:40:14 +00:00
parent f963c152cf
commit 3b0e2d8698
3 changed files with 11 additions and 4 deletions

View File

@ -15,8 +15,6 @@
#define OUTPUT_EXPORT_FILE_MAGIC "Monero output export\003"
#include "net/http_base.h"
#include "net/http_server_handlers_map2.h"
#include "net/http_client.h"
#include "storages/http_abstract_invoke.h"

View File

@ -656,11 +656,14 @@ public:
mstch::map context {
{"mempool_size", std::to_string(mempool_txs.size())},
};
context.emplace("mempooltxs" , mstch::array());
// get reference to blocks template map to be field below
mstch::array& txs = boost::get<mstch::array>(context["mempooltxs"]);
uint64_t mempool_size_bytes {0};
// for each transaction in the memory pool
for (size_t i = 0; i < mempool_txs.size(); ++i)
{
@ -744,10 +747,16 @@ public:
{"is_ringct" , is_ringct_str},
{"rct_type" , rct_type_str},
{"mixin" , fmt::format("{:d}", mixin_no)},
{"txsize" , fmt::format("{:0.2f}", static_cast<double>(_tx_info.blob_size)/1024.0)}
{"txsize" , fmt::format("{:0.2f}",
static_cast<double>(_tx_info.blob_size)/1024.0)}
});
mempool_size_bytes += _tx_info.blob_size;
}
context.insert({"mempool_size_kB",
fmt::format("{:0.2f}", static_cast<double>(mempool_size_bytes)/1024.0)});
// sort txs in mempool based on their age
std::sort(txs.begin(), txs.end(), [](mstch::node& m1, mstch::node& m2)
{

View File

@ -1,5 +1,5 @@
<h2>
Memory pool (size: {{mempool_size}})
Memory pool (no of txs: {{mempool_size}}, size: {{mempool_size_kB}} kB)
</h2>
<div class="center">