Skip to content

Commit 651fb03

Browse files
committed
Merge bitcoin#29260: refactor: remove CTxMemPool::queryHashes()
282b12d refactor: remove CTxMemPool::queryHashes() (stickies-v) Pull request description: `CTxMemPool::queryHashes()` is only used in `MempoolToJSON()`, where it can just as easily be replaced with the more general `CTxMemPool::entryAll()`. No behaviour change, just cleans up the code. ACKs for top commit: dergoegge: Code review ACK 282b12d TheCharlatan: ACK 282b12d glozow: ACK 282b12d. Looks like there's no conflicts. Tree-SHA512: 16160dec8e1f2457fa0f62dc96d2d2efd92c4bab810ecdb0e08918b8e85a667702c8e41421eeb4ea6abe92a5956a2a39a7a6368514973b78be0d22de2ad299b2
2 parents 0375244 + 282b12d commit 651fb03

File tree

4 files changed

+5
-23
lines changed

4 files changed

+5
-23
lines changed

src/rpc/mempool.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,15 @@ UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose, bool include_mempoo
353353
}
354354
return o;
355355
} else {
356+
UniValue a(UniValue::VARR);
356357
uint64_t mempool_sequence;
357-
std::vector<uint256> vtxid;
358358
{
359359
LOCK(pool.cs);
360-
pool.queryHashes(vtxid);
360+
for (const CTxMemPoolEntry& e : pool.entryAll()) {
361+
a.push_back(e.GetTx().GetHash().ToString());
362+
}
361363
mempool_sequence = pool.GetSequence();
362364
}
363-
UniValue a(UniValue::VARR);
364-
for (const uint256& hash : vtxid)
365-
a.push_back(hash.ToString());
366-
367365
if (!include_mempool_sequence) {
368366
return a;
369367
} else {

src/test/fuzz/tx_pool.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, Cha
101101
if (!info_all.empty()) {
102102
const auto& tx_to_remove = *PickValue(fuzzed_data_provider, info_all).tx;
103103
WITH_LOCK(tx_pool.cs, tx_pool.removeRecursive(tx_to_remove, MemPoolRemovalReason::BLOCK /* dummy */));
104-
std::vector<uint256> all_txids;
105-
tx_pool.queryHashes(all_txids);
106-
assert(all_txids.size() < info_all.size());
104+
assert(tx_pool.size() < info_all.size());
107105
WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));
108106
}
109107
SyncWithValidationInterfaceQueue();

src/txmempool.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -803,19 +803,6 @@ std::vector<CTxMemPool::indexed_transaction_set::const_iterator> CTxMemPool::Get
803803
return iters;
804804
}
805805

806-
void CTxMemPool::queryHashes(std::vector<uint256>& vtxid) const
807-
{
808-
LOCK(cs);
809-
auto iters = GetSortedDepthAndScore();
810-
811-
vtxid.clear();
812-
vtxid.reserve(mapTx.size());
813-
814-
for (auto it : iters) {
815-
vtxid.push_back(it->GetTx().GetHash());
816-
}
817-
}
818-
819806
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
820807
return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), it->GetFee(), it->GetTxSize(), it->GetModifiedFee() - it->GetFee()};
821808
}

src/txmempool.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ class CTxMemPool
485485
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
486486

487487
bool CompareDepthAndScore(const uint256& hasha, const uint256& hashb, bool wtxid=false);
488-
void queryHashes(std::vector<uint256>& vtxid) const;
489488
bool isSpent(const COutPoint& outpoint) const;
490489
unsigned int GetTransactionsUpdated() const;
491490
void AddTransactionsUpdated(unsigned int n);

0 commit comments

Comments
 (0)