diff --git a/src/node/miner.cpp b/src/node/miner.cpp index e8bfa973360fcf..e2d07612cf0e08 100644 --- a/src/node/miner.cpp +++ b/src/node/miner.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ using MemPoolMultiIndex::ancestor_score; using MemPoolMultiIndex::CompareTxMemPoolEntryByAncestorFee; +using MemPoolMultiIndex::indexed_transaction_set; using MemPoolMultiIndex::raw_txiter; // Container for tracking updates to ancestor feerate as we include (parent) @@ -413,7 +415,7 @@ void BlockAssembler::addPackageTxs(const CTxMemPool& mempool, int& nPackagesSele // Keep track of entries that failed inclusion, to avoid duplicate work std::set failedTx; - CTxMemPool::indexed_transaction_set::index::type::iterator mi = mempool.mapTx->impl.get().begin(); + indexed_transaction_set::index::type::iterator mi = mempool.mapTx->impl.get().begin(); raw_txiter iter; // Limit the number of attempts to add transactions to the block when it is diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index 91a3b0d97abac1..0d8297ce5e50d7 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -3,6 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include #include #include #include @@ -15,6 +16,7 @@ using MemPoolMultiIndex::ancestor_score; using MemPoolMultiIndex::descendant_score; +using MemPoolMultiIndex::indexed_transaction_set; BOOST_FIXTURE_TEST_SUITE(mempool_tests, TestingSetup) @@ -122,7 +124,7 @@ template static void CheckSort(CTxMemPool& pool, std::vector& sortedOrder) EXCLUSIVE_LOCKS_REQUIRED(pool.cs) { BOOST_CHECK_EQUAL(pool.size(), sortedOrder.size()); - typename CTxMemPool::indexed_transaction_set::index::type::iterator it = pool.mapTx->impl.get().begin(); + typename indexed_transaction_set::index::type::iterator it = pool.mapTx->impl.get().begin(); int count = 0; for (; it != pool.mapTx->impl.get().end(); ++it, ++count) { BOOST_CHECK_EQUAL(it->GetTx().GetHash().ToString(), sortedOrder[count]); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index fbb4ebbf572486..f8f28b2713341a 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,7 @@ using MemPoolMultiIndex::CompareTxMemPoolEntryByScore; using MemPoolMultiIndex::descendant_score; using MemPoolMultiIndex::entry_time; +using MemPoolMultiIndex::indexed_transaction_set; using MemPoolMultiIndex::MapTxImpl; using MemPoolMultiIndex::raw_setEntries; using MemPoolMultiIndex::raw_txiter; @@ -423,6 +425,8 @@ CTxMemPool::CTxMemPool(const Options& opts) { } +CTxMemPool::~CTxMemPool() = default; + bool CTxMemPool::isSpent(const COutPoint& outpoint) const { LOCK(cs); @@ -679,7 +683,7 @@ namespace { class DepthAndScoreComparator { public: - bool operator()(const CTxMemPool::indexed_transaction_set::const_iterator& a, const CTxMemPool::indexed_transaction_set::const_iterator& b) + bool operator()(const indexed_transaction_set::const_iterator& a, const indexed_transaction_set::const_iterator& b) { uint64_t counta = a->GetCountWithAncestors(); uint64_t countb = b->GetCountWithAncestors(); @@ -691,15 +695,15 @@ class DepthAndScoreComparator }; } // namespace -static std::vector GetSortedDepthAndScore( - const std::unique_ptr& mapTx, RecursiveMutex& cs) EXCLUSIVE_LOCKS_REQUIRED(cs) +static std::vector GetSortedDepthAndScore( + const std::unique_ptr& mapTx, RecursiveMutex& cs) EXCLUSIVE_LOCKS_REQUIRED(cs) { - std::vector iters; + std::vector iters; AssertLockHeld(cs); iters.reserve(mapTx->impl.size()); - for (MemPoolMultiIndex::indexed_transaction_set::iterator mi = mapTx->impl.begin(); mi != mapTx->impl.end(); ++mi) { + for (indexed_transaction_set::iterator mi = mapTx->impl.begin(); mi != mapTx->impl.end(); ++mi) { iters.push_back(mi); } std::sort(iters.begin(), iters.end(), DepthAndScoreComparator()); @@ -844,7 +848,8 @@ void CTxMemPool::queryHashes(std::vector& vtxid) const } } -static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) { +static TxMempoolInfo GetInfo(indexed_transaction_set::const_iterator it) +{ return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), it->GetFee(), it->GetTxSize(), it->GetModifiedFee() - it->GetFee()}; } diff --git a/src/txmempool.h b/src/txmempool.h index 3e51c0dd409114..a24e7c49e50bf3 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -14,7 +14,6 @@ #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export -#include #include #include #include @@ -34,6 +33,12 @@ class CChain; +namespace MemPoolMultiIndex { +struct txiter; +struct MapTxImpl; +struct setEntries; +} // namespace MemPoolMultiIndex + /** Fake height value used in Coin to signify they are only in the memory pool (since 0.8) */ static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF; @@ -197,7 +202,6 @@ class CTxMemPool * the mempool is consistent with the new chain tip and fully populated. */ - using indexed_transaction_set = MemPoolMultiIndex::indexed_transaction_set; using MapTxImpl = MemPoolMultiIndex::MapTxImpl; mutable RecursiveMutex cs; @@ -272,6 +276,8 @@ class CTxMemPool */ explicit CTxMemPool(const Options& opts); + ~CTxMemPool(); + /** * If sanity-checking is turned on, check makes sure the pool is * consistent (does not contain two transactions that spend the same inputs,