diff options
author | luigi1111 <luigi1111w@gmail.com> | 2024-03-08 20:27:34 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2024-03-08 20:27:34 -0500 |
commit | 1bec71279e43bfde46506409377630c7e020a1cf (patch) | |
tree | 28f413a7fecde03b1b4e1452afba9a4e19ab73b0 /src | |
parent | Merge pull request #9219 (diff) | |
parent | Fixed mempool pruning (diff) | |
download | monero-1bec71279e43bfde46506409377630c7e020a1cf.tar.xz |
Merge pull request #9225
a01d7cc Fixed mempool pruning (SChernykh)
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptonote_core/tx_pool.cpp | 15 | ||||
-rw-r--r-- | src/cryptonote_core/tx_pool.h | 11 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index f70db2b74..4f0501c1d 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -435,8 +435,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; @@ -481,8 +487,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) @@ -1827,7 +1838,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 { diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h index 3bb96d3a8..3a111ce91 100644 --- a/src/cryptonote_core/tx_pool.h +++ b/src/cryptonote_core/tx_pool.h @@ -69,11 +69,12 @@ namespace cryptonote { // sort by greatest first, not least if (a.first.first > b.first.first) return true; - else if (a.first.first < b.first.first) return false; - else if (a.first.second < b.first.second) return true; - else if (a.first.second > b.first.second) return false; - else if (a.second != b.second) return true; - else return false; + if (a.first.first < b.first.first) return false; + + if (a.first.second < b.first.second) return true; + if (a.first.second > b.first.second) return false; + + return memcmp(a.second.data, b.second.data, sizeof(crypto::hash)) < 0; } }; |