diff --git a/src/mempool_set_definitions.h b/src/mempool_set_definitions.h index a086bd7d912611..7d9b08a6b473c4 100644 --- a/src/mempool_set_definitions.h +++ b/src/mempool_set_definitions.h @@ -221,8 +221,6 @@ struct txiter { : impl(inner_impl) {} }; -typedef std::set setEntries; - typedef indexed_transaction_set::const_iterator const_txiter; } // namespace MemPoolMultiIndex 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 f11d5b8f467a04..cd33aa5035931e 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 ffd08ca0846a2f..774f9387b230cb 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ typedef std::set setEntrie using MemPoolMultiIndex::CompareTxMemPoolEntryByScore; using MemPoolMultiIndex::descendant_score; using MemPoolMultiIndex::entry_time; +using MemPoolMultiIndex::indexed_transaction_set; using MemPoolMultiIndex::MapTxImpl; using MemPoolMultiIndex::raw_txiter; using MemPoolMultiIndex::txiter; @@ -422,6 +424,8 @@ CTxMemPool::CTxMemPool(const Options& opts) { } +CTxMemPool::~CTxMemPool() = default; + bool CTxMemPool::isSpent(const COutPoint& outpoint) const { LOCK(cs); @@ -677,7 +681,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(); @@ -689,15 +693,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()); @@ -842,7 +846,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 b50d03490082f0..0e709e62d1f735 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,11 @@ class CChain; +namespace MemPoolMultiIndex { +struct txiter; +struct MapTxImpl; +} // 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 +201,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; @@ -271,6 +274,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,