aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSChernykh <15806605+SChernykh@users.noreply.github.com>2024-03-08 14:50:01 +0100
committerSChernykh <15806605+SChernykh@users.noreply.github.com>2024-03-08 14:51:33 +0100
commit36ee12bd8d20aecf67fbfe5387749b1562732528 (patch)
tree6ebbe14eb44d611855387e303e00b1be9361013b
parentMerge pull request #9217 (diff)
downloadmonero-36ee12bd8d20aecf67fbfe5387749b1562732528.tar.xz
get_block_template_backlog: better sorting logic
std::sort is unstable, so it can return random sets of transactions when mempool has many transactions with the same fee/byte. It can result in p2pool mining empty blocks sometimes because it doesn't pick up "new" transactions immediately.
-rw-r--r--src/cryptonote_core/tx_pool.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 36fea56a3..11efff664 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -1074,7 +1074,7 @@ namespace cryptonote
// If the total weight is too high, choose the best paying transactions
if (total_weight > max_backlog_weight)
- std::sort(tmp.begin(), tmp.end(), [](const auto& a, const auto& b){ return a.fee * b.weight > b.fee * a.weight; });
+ std::stable_sort(tmp.begin(), tmp.end(), [](const auto& a, const auto& b){ return a.fee * b.weight > b.fee * a.weight; });
backlog.clear();
uint64_t w = 0;