diff options
author | SChernykh <15806605+SChernykh@users.noreply.github.com> | 2024-03-08 14:50:01 +0100 |
---|---|---|
committer | SChernykh <15806605+SChernykh@users.noreply.github.com> | 2024-03-08 14:50:01 +0100 |
commit | 66e5081eae81e33f1352b27d856c5ef1f7f9087b (patch) | |
tree | 7f7f0af7e9df162ae4f164a4a312664467065f7c | |
parent | Merge pull request #9214 (diff) | |
download | monero-66e5081eae81e33f1352b27d856c5ef1f7f9087b.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.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index d86a9f5f9..a54005176 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -1073,7 +1073,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; |