From fa5760880094c4e4238249f6d1837cd74383cc3a Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Mon, 7 Aug 2023 09:50:59 +0200 Subject: [PATCH 1/4] Remove unused includes from txmempool.h ... and move them to where they are really needed. This was found by IWYU: txmempool.h should remove these lines: - #include // lines 29-29 - class CBlockIndex; // lines 43-43 - class Chainstate; // lines 45-45 Also, move the stdlib section to the right place. Can be reviewed with: --color-moved=dimmed-zebra --- src/node/miner.h | 3 ++- src/test/miniminer_tests.cpp | 1 + src/txmempool.h | 21 +++++++++------------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/node/miner.h b/src/node/miner.h index 70de9e1db0f..41735215854 100644 --- a/src/node/miner.h +++ b/src/node/miner.h @@ -21,10 +21,11 @@ #include class ArgsManager; -class ChainstateManager; class CBlockIndex; class CChainParams; class CScript; +class Chainstate; +class ChainstateManager; namespace Consensus { struct Params; }; diff --git a/src/test/miniminer_tests.cpp b/src/test/miniminer_tests.cpp index 1ee9e0c0664..da724f8d7b9 100644 --- a/src/test/miniminer_tests.cpp +++ b/src/test/miniminer_tests.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include #include #include diff --git a/src/txmempool.h b/src/txmempool.h index 4d7d53ff687..afaaf0d4d67 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -6,15 +6,6 @@ #ifndef BITCOIN_TXMEMPOOL_H #define BITCOIN_TXMEMPOOL_H -#include -#include -#include -#include -#include -#include -#include -#include - #include #include @@ -26,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -40,9 +30,16 @@ #include #include -class CBlockIndex; +#include +#include +#include +#include +#include +#include +#include +#include + class CChain; -class Chainstate; /** 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; From fad8c36aa9011c3f7b1183f8380577e16a2167a6 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 2 Aug 2023 15:51:00 +0200 Subject: [PATCH 2/4] move-only: Create src/kernel/mempool_removal_reason.h This is needed for a future commit. Can be reviewed with: --color-moved=dimmed-zebra --- src/Makefile.am | 3 +++ src/kernel/mempool_removal_reason.cpp | 21 +++++++++++++++++++++ src/kernel/mempool_removal_reason.h | 24 ++++++++++++++++++++++++ src/txmempool.cpp | 13 ------------- src/txmempool.h | 22 ++++------------------ 5 files changed, 52 insertions(+), 31 deletions(-) create mode 100644 src/kernel/mempool_removal_reason.cpp create mode 100644 src/kernel/mempool_removal_reason.h diff --git a/src/Makefile.am b/src/Makefile.am index 1f953ab624a..feed4a0061c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -190,6 +190,7 @@ BITCOIN_CORE_H = \ kernel/mempool_limits.h \ kernel/mempool_options.h \ kernel/mempool_persist.h \ + kernel/mempool_removal_reason.h \ kernel/notifications_interface.h \ kernel/validation_cache_sizes.h \ key.h \ @@ -401,6 +402,7 @@ libbitcoin_node_a_SOURCES = \ kernel/context.cpp \ kernel/cs_main.cpp \ kernel/mempool_persist.cpp \ + kernel/mempool_removal_reason.cpp \ mapport.cpp \ net.cpp \ net_processing.cpp \ @@ -940,6 +942,7 @@ libbitcoinkernel_la_SOURCES = \ kernel/context.cpp \ kernel/cs_main.cpp \ kernel/mempool_persist.cpp \ + kernel/mempool_removal_reason.cpp \ key.cpp \ logging.cpp \ node/blockstorage.cpp \ diff --git a/src/kernel/mempool_removal_reason.cpp b/src/kernel/mempool_removal_reason.cpp new file mode 100644 index 00000000000..df27590c7ab --- /dev/null +++ b/src/kernel/mempool_removal_reason.cpp @@ -0,0 +1,21 @@ +// Copyright (c) 2016-present The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://opensource.org/license/mit/. + +#include + +#include +#include + +std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept +{ + switch (r) { + case MemPoolRemovalReason::EXPIRY: return "expiry"; + case MemPoolRemovalReason::SIZELIMIT: return "sizelimit"; + case MemPoolRemovalReason::REORG: return "reorg"; + case MemPoolRemovalReason::BLOCK: return "block"; + case MemPoolRemovalReason::CONFLICT: return "conflict"; + case MemPoolRemovalReason::REPLACED: return "replaced"; + } + assert(false); +} diff --git a/src/kernel/mempool_removal_reason.h b/src/kernel/mempool_removal_reason.h new file mode 100644 index 00000000000..53c2ff1c31c --- /dev/null +++ b/src/kernel/mempool_removal_reason.h @@ -0,0 +1,24 @@ +// Copyright (c) 2016-present The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://opensource.org/license/mit/. + +#ifndef BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H +#define BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H + +#include + +/** Reason why a transaction was removed from the mempool, + * this is passed to the notification signal. + */ +enum class MemPoolRemovalReason { + EXPIRY, //!< Expired from mempool + SIZELIMIT, //!< Removed in size limiting + REORG, //!< Removed for reorganization + BLOCK, //!< Removed for block + CONFLICT, //!< Removed for conflict with in-block transaction + REPLACED, //!< Removed for replacement +}; + +std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept; + +#endif // BITCOIN_KERNEL_MEMPOOL_REMOVAL_REASON_H diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 497a41d6a90..226dd9f3532 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -1197,19 +1197,6 @@ void CTxMemPool::SetLoadTried(bool load_tried) m_load_tried = load_tried; } -std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept -{ - switch (r) { - case MemPoolRemovalReason::EXPIRY: return "expiry"; - case MemPoolRemovalReason::SIZELIMIT: return "sizelimit"; - case MemPoolRemovalReason::REORG: return "reorg"; - case MemPoolRemovalReason::BLOCK: return "block"; - case MemPoolRemovalReason::CONFLICT: return "conflict"; - case MemPoolRemovalReason::REPLACED: return "replaced"; - } - assert(false); -} - std::vector CTxMemPool::GatherClusters(const std::vector& txids) const { AssertLockHeld(cs); diff --git a/src/txmempool.h b/src/txmempool.h index afaaf0d4d67..869612a4a2d 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -6,14 +6,14 @@ #ifndef BITCOIN_TXMEMPOOL_H #define BITCOIN_TXMEMPOOL_H -#include -#include - #include #include #include #include -#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export #include #include #include @@ -225,20 +225,6 @@ struct TxMempoolInfo int64_t nFeeDelta; }; -/** Reason why a transaction was removed from the mempool, - * this is passed to the notification signal. - */ -enum class MemPoolRemovalReason { - EXPIRY, //!< Expired from mempool - SIZELIMIT, //!< Removed in size limiting - REORG, //!< Removed for reorganization - BLOCK, //!< Removed for block - CONFLICT, //!< Removed for conflict with in-block transaction - REPLACED, //!< Removed for replacement -}; - -std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept; - /** * CTxMemPool stores valid-according-to-the-current-best-chain transactions * that may be included in the next block. From fa8fdbe22932a4717d2bc4060269da9bff228728 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Mon, 7 Aug 2023 10:17:31 +0200 Subject: [PATCH 3/4] Remove unused includes from blockfilter.h This removes unused includes, primitives/block found manually, and the others by iwyu: blockfilter.h should remove these lines: - #include // lines 16-16 - #include // lines 18-18 --- src/blockfilter.cpp | 2 ++ src/blockfilter.h | 13 ++++++++----- src/index/blockfilterindex.cpp | 1 + src/index/blockfilterindex.h | 2 ++ src/test/blockfilter_tests.cpp | 2 ++ src/test/util/blockfilter.cpp | 2 ++ src/wallet/test/util.cpp | 1 + src/wallet/test/wallet_tests.cpp | 1 + 8 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/blockfilter.cpp b/src/blockfilter.cpp index 2f465f1119b..985a81f5228 100644 --- a/src/blockfilter.cpp +++ b/src/blockfilter.cpp @@ -8,9 +8,11 @@ #include #include #include +#include #include #include