aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstickies-v <stickies-v@protonmail.com>2024-01-17 12:51:08 +0000
committerstickies-v <stickies-v@protonmail.com>2024-01-18 21:54:56 +0000
commit282b12ddb0aeb1f0991dd9f45c6b5c5c079652ec (patch)
treee81dea1d80aa5333d441a10db131ede282d8219d
parentc818607ed59eb87be65b558f34bd6df049f6b238 (diff)
downloadbitcoin-282b12ddb0aeb1f0991dd9f45c6b5c5c079652ec.tar.xz
refactor: remove CTxMemPool::queryHashes()
Its only usage can easily be replaced with CTxMemPool::entryAll()
-rw-r--r--src/rpc/mempool.cpp10
-rw-r--r--src/test/fuzz/tx_pool.cpp4
-rw-r--r--src/txmempool.cpp13
-rw-r--r--src/txmempool.h1
4 files changed, 5 insertions, 23 deletions
diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp
index f6d9d42f0f..04d2e68939 100644
--- a/src/rpc/mempool.cpp
+++ b/src/rpc/mempool.cpp
@@ -353,17 +353,15 @@ UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose, bool include_mempoo
}
return o;
} else {
+ UniValue a(UniValue::VARR);
uint64_t mempool_sequence;
- std::vector<uint256> vtxid;
{
LOCK(pool.cs);
- pool.queryHashes(vtxid);
+ for (const CTxMemPoolEntry& e : pool.entryAll()) {
+ a.push_back(e.GetTx().GetHash().ToString());
+ }
mempool_sequence = pool.GetSequence();
}
- UniValue a(UniValue::VARR);
- for (const uint256& hash : vtxid)
- a.push_back(hash.ToString());
-
if (!include_mempool_sequence) {
return a;
} else {
diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp
index 4ad0956201..8c0b0d7029 100644
--- a/src/test/fuzz/tx_pool.cpp
+++ b/src/test/fuzz/tx_pool.cpp
@@ -101,9 +101,7 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, Cha
if (!info_all.empty()) {
const auto& tx_to_remove = *PickValue(fuzzed_data_provider, info_all).tx;
WITH_LOCK(tx_pool.cs, tx_pool.removeRecursive(tx_to_remove, MemPoolRemovalReason::BLOCK /* dummy */));
- std::vector<uint256> all_txids;
- tx_pool.queryHashes(all_txids);
- assert(all_txids.size() < info_all.size());
+ assert(tx_pool.size() < info_all.size());
WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));
}
SyncWithValidationInterfaceQueue();
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index acee56fe78..57a86549d9 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -803,19 +803,6 @@ std::vector<CTxMemPool::indexed_transaction_set::const_iterator> CTxMemPool::Get
return iters;
}
-void CTxMemPool::queryHashes(std::vector<uint256>& vtxid) const
-{
- LOCK(cs);
- auto iters = GetSortedDepthAndScore();
-
- vtxid.clear();
- vtxid.reserve(mapTx.size());
-
- for (auto it : iters) {
- vtxid.push_back(it->GetTx().GetHash());
- }
-}
-
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), it->GetFee(), it->GetTxSize(), it->GetModifiedFee() - it->GetFee()};
}
diff --git a/src/txmempool.h b/src/txmempool.h
index 9da51756e6..ca842632da 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -485,7 +485,6 @@ public:
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
bool CompareDepthAndScore(const uint256& hasha, const uint256& hashb, bool wtxid=false);
- void queryHashes(std::vector<uint256>& vtxid) const;
bool isSpent(const COutPoint& outpoint) const;
unsigned int GetTransactionsUpdated() const;
void AddTransactionsUpdated(unsigned int n);