Skip to content

Commit 468a8d4

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 af926ae commit 468a8d4

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
@@ -349,17 +349,15 @@ UniValue MempoolToJSON(const CTxMemPool& pool, const llmq::CInstantSendManager*
349349
}
350350
return o;
351351
} else {
352+
UniValue a(UniValue::VARR);
352353
uint64_t mempool_sequence;
353-
std::vector<uint256> vtxid;
354354
{
355355
LOCK(pool.cs);
356-
pool.queryHashes(vtxid);
356+
for (const CTxMemPoolEntry& e : pool.entryAll()) {
357+
a.push_back(e.GetTx().GetHash().ToString());
358+
}
357359
mempool_sequence = pool.GetSequence();
358360
}
359-
UniValue a(UniValue::VARR);
360-
for (const uint256& hash : vtxid)
361-
a.push_back(hash.ToString());
362-
363361
if (!include_mempool_sequence) {
364362
return a;
365363
} 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
@@ -641,7 +641,6 @@ class CTxMemPool
641641
void clear();
642642
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); //lock free
643643
bool CompareDepthAndScore(const uint256& hasha, const uint256& hashb);
644-
void queryHashes(std::vector<uint256>& vtxid) const;
645644
bool isSpent(const COutPoint& outpoint) const;
646645
unsigned int GetTransactionsUpdated() const;
647646
void AddTransactionsUpdated(unsigned int n);

0 commit comments

Comments
 (0)