From 749bb447f819428d4836c9f205d5212283fa3eac Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Thu, 19 Feb 2026 21:07:10 +1000 Subject: [PATCH] txmempool: Drop CompareMiningScoreWithTopology Now unused; replaced by ExtractBestByMiningScoreWithTopology. --- src/txmempool.cpp | 25 ++++--------------------- src/txmempool.h | 1 - 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 4bb86c9bace..e5ec3b32cab 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -458,7 +458,7 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei assert(diagram.size() <= score_with_topo.size() + 1); assert(diagram.size() >= 1); - std::optional last_wtxid = std::nullopt; + std::optional last_iter = std::nullopt; auto diagram_iter = diagram.cbegin(); for (const auto& it : score_with_topo) { @@ -480,11 +480,10 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei innerUsage += it->DynamicMemoryUsage(); const CTransaction& tx = it->GetTx(); - // CompareMiningScoreWithTopology should agree with GetSortedScoreWithTopology() - if (last_wtxid) { - assert(CompareMiningScoreWithTopology(*last_wtxid, tx.GetWitnessHash())); + if (last_iter) { + assert(m_txgraph->CompareMainOrder(**last_iter, *it) < 0); } - last_wtxid = tx.GetWitnessHash(); + last_iter = it; std::set setParentCheck; std::set setParentsStored; @@ -611,22 +610,6 @@ std::vector CTxMemPool::ExtractBestByMiningScoreWithTopology return res; } -bool CTxMemPool::CompareMiningScoreWithTopology(const Wtxid& hasha, const Wtxid& hashb) const -{ - /* Return `true` if hasha should be considered sooner than hashb, namely when: - * a is not in the mempool but b is, or - * both are in the mempool but a is sorted before b in the total mempool ordering - * (which takes dependencies and (chunk) feerates into account). - */ - LOCK(cs); - auto j{GetIter(hashb)}; - if (!j.has_value()) return false; - auto i{GetIter(hasha)}; - if (!i.has_value()) return true; - - return m_txgraph->CompareMainOrder(*i.value(), *j.value()) < 0; -} - std::vector CTxMemPool::GetSortedScoreWithTopology() const { std::vector iters; diff --git a/src/txmempool.h b/src/txmempool.h index dcc9ed874e7..d2324d1c79d 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -344,7 +344,6 @@ public: * mempool.cs is released. */ std::vector ExtractBestByMiningScoreWithTopology(std::vector& wtxids, size_t n_to_sort) const EXCLUSIVE_LOCKS_REQUIRED(cs); - bool CompareMiningScoreWithTopology(const Wtxid& hasha, const Wtxid& hashb) const; bool isSpent(const COutPoint& outpoint) const; unsigned int GetTransactionsUpdated() const; void AddTransactionsUpdated(unsigned int n);