From 9d22729be04ce68c1dd84d86aee4047f534dfbe3 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 12 Jan 2017 02:55:38 +0000 Subject: [PATCH] mempool txs are sorted by age now --- src/page.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/page.h b/src/page.h index 301b1bd..688c076 100644 --- a/src/page.h +++ b/src/page.h @@ -732,6 +732,7 @@ public: // set output page template map txs.push_back(mstch::map { + {"timestamp_no" , _tx_info.receive_time}, {"timestamp" , xmreg::timestamp_to_str(_tx_info.receive_time)}, {"age" , age_str}, {"hash" , fmt::format("{:s}", _tx_info.id_hash)}, @@ -747,6 +748,15 @@ public: }); } + // sort txs in mempool based on their age + std::sort(txs.begin(), txs.end(), [](mstch::node& m1, mstch::node& m2) + { + uint64_t t1 = boost::get(boost::get(m1)["timestamp_no"]); + uint64_t t2 = boost::get(boost::get(m2)["timestamp_no"]); + + return t1 > t2; + }); + // read index.html string mempool_html = xmreg::read(TMPL_MEMPOOL);