aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorstickies-v <stickies-v@protonmail.com>2023-11-09 17:51:20 +0100
committerglozow <gloriajzhao@gmail.com>2024-01-19 16:12:23 +0000
commitfc62271015e9585bd3a3889adac894c9ef2e2ab2 (patch)
tree60b4d2a52636ba6ca4801261c8fc7f25fefe195c /src/txmempool.cpp
parent04edf9f5862c3ca2d1aed6b7a0f24b8d2914f96c (diff)
[refactor] Add helper for iterating through mempool entries
Instead of reaching into the mapTx data structure, use a helper method that provides the required vector of CTxMemPoolEntry pointers. Github-Pull: #28391 Rebased-From: 453b4813ebc74859864803e9972b58e4be76a4d6
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 461662ad93..8b744698ba 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -836,6 +836,18 @@ static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator
return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), it->GetFee(), it->GetTxSize(), it->GetModifiedFee() - it->GetFee()};
}
+std::vector<CTxMemPoolEntryRef> CTxMemPool::entryAll() const
+{
+ AssertLockHeld(cs);
+
+ std::vector<CTxMemPoolEntryRef> ret;
+ ret.reserve(mapTx.size());
+ for (const auto& it : GetSortedDepthAndScore()) {
+ ret.emplace_back(*it);
+ }
+ return ret;
+}
+
std::vector<TxMempoolInfo> CTxMemPool::infoAll() const
{
LOCK(cs);