[refactor] Add helper for retrieving mempool entry

In places where the iterator is only needed for accessing the actual
entry, it should not be required to first retrieve the iterator.
This commit is contained in:
TheCharlatan
2023-11-02 15:50:45 +01:00
parent 453b4813eb
commit 1c6a73abbd
5 changed files with 26 additions and 18 deletions

View File

@@ -862,6 +862,13 @@ std::vector<TxMempoolInfo> CTxMemPool::infoAll() const
return ret;
}
const CTxMemPoolEntry* CTxMemPool::GetEntry(const Txid& txid) const
{
AssertLockHeld(cs);
const auto i = mapTx.find(txid);
return i == mapTx.end() ? nullptr : &(*i);
}
CTransactionRef CTxMemPool::get(const uint256& hash) const
{
LOCK(cs);