diff options
author | luigi1111 <luigi1111w@gmail.com> | 2019-09-30 18:49:09 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2019-09-30 18:49:09 -0500 |
commit | d9cb50870d8cd773b5218b01f1521b63a9a2f621 (patch) | |
tree | 094325982a240801fe710b97aaa2ede82937c9a0 /src/cryptonote_core | |
parent | Merge pull request #5896 (diff) | |
parent | Fix bug in mempool get_transaction_stats histogram calculation (diff) | |
download | monero-d9cb50870d8cd773b5218b01f1521b63a9a2f621.tar.xz |
Merge pull request #5900
6bbc646 Fix bug in mempool get_transaction_stats histogram calculation (tomsmeding)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/tx_pool.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 49d5a8ccc..5927e116a 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -733,7 +733,7 @@ namespace cryptonote if (meta.double_spend_seen) ++stats.num_double_spends; return true; - }, false, include_unrelayed_txes); + }, false, include_unrelayed_txes); stats.bytes_med = epee::misc_utils::median(weights); if (stats.txs_total > 1) { @@ -746,8 +746,15 @@ namespace cryptonote /* If enough txs, spread the first 98% of results across * the first 9 bins, drop final 2% in last bin. */ - it=agebytes.end(); - for (size_t n=0; n <= end; n++, it--); + it = agebytes.end(); + size_t cumulative_num = 0; + /* Since agebytes is not empty and end is nonzero, the + * below loop can always run at least once. + */ + do { + --it; + cumulative_num += it->second.txs; + } while (it != agebytes.begin() && cumulative_num < end); stats.histo_98pc = it->first; factor = 9; delta = it->first; |