diff options
| author | SChernykh <15806605+SChernykh@users.noreply.github.com> | 2024-03-08 20:58:21 +0100 |
|---|---|---|
| committer | SChernykh <15806605+SChernykh@users.noreply.github.com> | 2024-03-08 21:03:41 +0100 |
| commit | b5b72ae05c5b47b76e57d565de0bac5706530c6a (patch) | |
| tree | c55c5d6dfb5c0c2895194df5685bbe1082d07034 /src/cryptonote_core/tx_pool.cpp | |
| parent | 5eb3fc29bbeef95c133d18a34c52aecb9f449b60 (diff) | |
| download | monzero-core-b5b72ae05c5b47b76e57d565de0bac5706530c6a.tar.gz monzero-core-b5b72ae05c5b47b76e57d565de0bac5706530c6a.tar.xz monzero-core-b5b72ae05c5b47b76e57d565de0bac5706530c6a.zip | |
Fixed mempool pruning
- Fixed undefined behavior after a call to `remove_tx_from_transient_lists` (it used an invalid iterator)
- Fixed `txCompare` (it wasn't strictly weak ordered)
Diffstat (limited to 'src/cryptonote_core/tx_pool.cpp')
| -rw-r--r-- | src/cryptonote_core/tx_pool.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 1de36be8f..2a3b7a5d5 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -436,8 +436,14 @@ namespace cryptonote void tx_memory_pool::prune(size_t bytes) { CRITICAL_REGION_LOCAL(m_transactions_lock); + + // Nothing to do if already empty + if (m_txs_by_fee_and_receive_time.empty()) + return; + if (bytes == 0) bytes = m_txpool_max_weight; + CRITICAL_REGION_LOCAL1(m_blockchain); LockedTXN lock(m_blockchain.get_db()); bool changed = false; @@ -482,8 +488,13 @@ namespace cryptonote reduce_txpool_weight(meta.weight); remove_transaction_keyimages(tx, txid); MINFO("Pruned tx " << txid << " from txpool: weight: " << meta.weight << ", fee/byte: " << it->first.first); + + auto it_prev = it; + --it_prev; + remove_tx_from_transient_lists(it, txid, !meta.matches(relay_category::broadcasted)); - it--; + it = it_prev; + changed = true; } catch (const std::exception &e) @@ -1828,7 +1839,7 @@ namespace cryptonote auto sorted_it = find_tx_in_sorted_container(txid); if (sorted_it == m_txs_by_fee_and_receive_time.end()) { - MERROR("Re-adding tx " << txid << " to tx pool, but it was not found in the sorted txs container"); + MDEBUG("Re-adding tx " << txid << " to tx pool, but it was not found in the sorted txs container"); } else { |
