Skip to content

Commit e890b57

Browse files
glozowvijaydasmp
authored andcommitted
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
1 parent d1eab6c commit e890b57

4 files changed

Lines changed: 5 additions & 23 deletions

File tree

src/rpc/mempool.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,15 @@ UniValue MempoolToJSON(const CTxMemPool& pool, const llmq::CInstantSendManager*
350350
}
351351
return o;
352352
} else {
353+
UniValue a(UniValue::VARR);
353354
uint64_t mempool_sequence;
354-
std::vector<uint256> vtxid;
355355
{
356356
LOCK(pool.cs);
357-
pool.queryHashes(vtxid);
357+
for (const CTxMemPoolEntry& e : pool.entryAll()) {
358+
a.push_back(e.GetTx().GetHash().ToString());
359+
}
358360
mempool_sequence = pool.GetSequence();
359361
}
360-
UniValue a(UniValue::VARR);
361-
for (const uint256& hash : vtxid)
362-
a.push_back(hash.ToString());
363-
364362
if (!include_mempool_sequence) {
365363
return a;
366364
} else {

src/test/fuzz/tx_pool.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, con
107107
if (!info_all.empty()) {
108108
const auto& tx_to_remove = *PickValue(fuzzed_data_provider, info_all).tx;
109109
WITH_LOCK(tx_pool.cs, tx_pool.removeRecursive(tx_to_remove, MemPoolRemovalReason::BLOCK /* dummy */));
110-
std::vector<uint256> all_txids;
111-
tx_pool.queryHashes(all_txids);
112-
assert(all_txids.size() < info_all.size());
110+
assert(tx_pool.size() < info_all.size());
113111
WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));
114112
}
115113
SyncWithValidationInterfaceQueue();

src/txmempool.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,19 +1283,6 @@ std::vector<CTxMemPool::indexed_transaction_set::const_iterator> CTxMemPool::Get
12831283
return iters;
12841284
}
12851285

1286-
void CTxMemPool::queryHashes(std::vector<uint256>& vtxid) const
1287-
{
1288-
LOCK(cs);
1289-
auto iters = GetSortedDepthAndScore();
1290-
1291-
vtxid.clear();
1292-
vtxid.reserve(mapTx.size());
1293-
1294-
for (auto it : iters) {
1295-
vtxid.push_back(it->GetTx().GetHash());
1296-
}
1297-
}
1298-
12991286
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
13001287
return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), it->GetFee(), it->GetTxSize(), it->GetModifiedFee() - it->GetFee()};
13011288
}

src/txmempool.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,6 @@ class CTxMemPool
651651
void clear();
652652
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); //lock free
653653
bool CompareDepthAndScore(const uint256& hasha, const uint256& hashb);
654-
void queryHashes(std::vector<uint256>& vtxid) const;
655654
bool isSpent(const COutPoint& outpoint) const;
656655
unsigned int GetTransactionsUpdated() const;
657656
void AddTransactionsUpdated(unsigned int n);

0 commit comments

Comments
 (0)