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.
This commit is contained in:
parent
4b255808d0
commit
66e5081eae
|
@ -1073,7 +1073,7 @@ namespace cryptonote
|
||||||
|
|
||||||
// If the total weight is too high, choose the best paying transactions
|
// If the total weight is too high, choose the best paying transactions
|
||||||
if (total_weight > max_backlog_weight)
|
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();
|
backlog.clear();
|
||||||
uint64_t w = 0;
|
uint64_t w = 0;
|
||||||
|
|
Loading…
Reference in New Issue