diff options
author | fanquake <fanquake@gmail.com> | 2023-08-22 10:16:20 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-08-22 10:34:10 +0100 |
commit | 00fc7cdc2558c6766412a0c57870ed460f02e1d0 (patch) | |
tree | 18088ea35352ab2638d87f9973909dcce05057dd /src | |
parent | c00bc6306163197793d9ff52513fca430c6cae72 (diff) | |
parent | fa6286891fa4164510e4fbf4bc214ce3033b2d1b (diff) |
Merge bitcoin/bitcoin#28200: refactor: Remove unused includes from wallet.cpp
fa6286891fa4164510e4fbf4bc214ce3033b2d1b Remove unused includes from wallet.cpp (MarcoFalke)
fa8fdbe22932a4717d2bc4060269da9bff228728 Remove unused includes from blockfilter.h (MarcoFalke)
fad8c36aa9011c3f7b1183f8380577e16a2167a6 move-only: Create src/kernel/mempool_removal_reason.h (MarcoFalke)
fa5760880094c4e4238249f6d1837cd74383cc3a Remove unused includes from txmempool.h (MarcoFalke)
Pull request description:
This makes compilation of wallet.cpp use a few % less memory and time, locally.
Created in the context of https://github.com/bitcoin/bitcoin/issues/28109, but I don't think it is enough to actually fix this problem.
ACKs for top commit:
hebasto:
ACK fa6286891fa4164510e4fbf4bc214ce3033b2d1b, I have reviewed the code and it looks OK.
Tree-SHA512: 06f1120af2a8ef3368dbd9ae747acda88ace2507bd261bcc10341d476a0b3d71c8485377ea6c108b47df3e4c13b7f75a15f486bafa6a8466303168dde16ebbc8
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/blockfilter.cpp | 2 | ||||
-rw-r--r-- | src/blockfilter.h | 13 | ||||
-rw-r--r-- | src/index/blockfilterindex.cpp | 1 | ||||
-rw-r--r-- | src/index/blockfilterindex.h | 2 | ||||
-rw-r--r-- | src/kernel/mempool_removal_reason.cpp | 21 | ||||
-rw-r--r-- | src/kernel/mempool_removal_reason.h | 24 | ||||
-rw-r--r-- | src/node/miner.h | 3 | ||||
-rw-r--r-- | src/test/blockfilter_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/miniminer_tests.cpp | 1 | ||||
-rw-r--r-- | src/test/util/blockfilter.cpp | 2 | ||||
-rw-r--r-- | src/txmempool.cpp | 13 | ||||
-rw-r--r-- | src/txmempool.h | 43 | ||||
-rw-r--r-- | src/wallet/test/util.cpp | 1 | ||||
-rw-r--r-- | src/wallet/test/wallet_tests.cpp | 1 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 51 | ||||
-rw-r--r-- | src/wallet/wallet.h | 51 |
17 files changed, 161 insertions, 73 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 1f953ab624..feed4a0061 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/blockfilter.cpp b/src/blockfilter.cpp index 2f465f1119..985a81f522 100644 --- a/src/blockfilter.cpp +++ b/src/blockfilter.cpp @@ -8,9 +8,11 @@ #include <blockfilter.h> #include <crypto/siphash.h> #include <hash.h> +#include <primitives/block.h> #include <primitives/transaction.h> #include <script/script.h> #include <streams.h> +#include <undo.h> #include <util/golombrice.h> #include <util/string.h> diff --git a/src/blockfilter.h b/src/blockfilter.h index fb5114edb3..8eab4afa76 100644 --- a/src/blockfilter.h +++ b/src/blockfilter.h @@ -5,19 +5,22 @@ #ifndef BITCOIN_BLOCKFILTER_H #define BITCOIN_BLOCKFILTER_H -#include <stdint.h> -#include <string> +#include <cstddef> +#include <cstdint> +#include <ios> #include <set> +#include <string> #include <unordered_set> +#include <utility> #include <vector> #include <attributes.h> -#include <primitives/block.h> -#include <serialize.h> #include <uint256.h> -#include <undo.h> #include <util/bytevectorhash.h> +class CBlock; +class CBlockUndo; + /** * This implements a Golomb-coded set as defined in BIP 158. It is a * compact, probabilistic data structure for testing set membership. diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp index cc7d6687b8..b23d66ac1d 100644 --- a/src/index/blockfilterindex.cpp +++ b/src/index/blockfilterindex.cpp @@ -10,6 +10,7 @@ #include <index/blockfilterindex.h> #include <logging.h> #include <node/blockstorage.h> +#include <undo.h> #include <util/fs_helpers.h> #include <validation.h> diff --git a/src/index/blockfilterindex.h b/src/index/blockfilterindex.h index ce1961c776..10a1cfd2ee 100644 --- a/src/index/blockfilterindex.h +++ b/src/index/blockfilterindex.h @@ -12,6 +12,8 @@ #include <index/base.h> #include <util/hasher.h> +#include <unordered_map> + static const char* const DEFAULT_BLOCKFILTERINDEX = "0"; /** Interval between compact filter checkpoints. See BIP 157. */ diff --git a/src/kernel/mempool_removal_reason.cpp b/src/kernel/mempool_removal_reason.cpp new file mode 100644 index 0000000000..df27590c7a --- /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 <kernel/mempool_removal_reason.h> + +#include <cassert> +#include <string> + +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 0000000000..53c2ff1c31 --- /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 <string> + +/** 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/node/miner.h b/src/node/miner.h index 70de9e1db0..4173521585 100644 --- a/src/node/miner.h +++ b/src/node/miner.h @@ -21,10 +21,11 @@ #include <boost/multi_index_container.hpp> class ArgsManager; -class ChainstateManager; class CBlockIndex; class CChainParams; class CScript; +class Chainstate; +class ChainstateManager; namespace Consensus { struct Params; }; diff --git a/src/test/blockfilter_tests.cpp b/src/test/blockfilter_tests.cpp index dfeac6ca42..b372f25ea9 100644 --- a/src/test/blockfilter_tests.cpp +++ b/src/test/blockfilter_tests.cpp @@ -7,8 +7,10 @@ #include <blockfilter.h> #include <core_io.h> +#include <primitives/block.h> #include <serialize.h> #include <streams.h> +#include <undo.h> #include <univalue.h> #include <util/strencodings.h> diff --git a/src/test/miniminer_tests.cpp b/src/test/miniminer_tests.cpp index 1ee9e0c066..da724f8d7b 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 <node/mini_miner.h> +#include <random.h> #include <txmempool.h> #include <util/time.h> diff --git a/src/test/util/blockfilter.cpp b/src/test/util/blockfilter.cpp index a806844e34..19f3d51d5e 100644 --- a/src/test/util/blockfilter.cpp +++ b/src/test/util/blockfilter.cpp @@ -6,6 +6,8 @@ #include <chainparams.h> #include <node/blockstorage.h> +#include <primitives/block.h> +#include <undo.h> #include <validation.h> using node::BlockManager; diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 497a41d6a9..226dd9f353 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::txiter> CTxMemPool::GatherClusters(const std::vector<uint256>& txids) const { AssertLockHeld(cs); diff --git a/src/txmempool.h b/src/txmempool.h index 4d7d53ff68..869612a4a2 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -6,27 +6,17 @@ #ifndef BITCOIN_TXMEMPOOL_H #define BITCOIN_TXMEMPOOL_H -#include <atomic> -#include <map> -#include <optional> -#include <set> -#include <string> -#include <string_view> -#include <utility> -#include <vector> - -#include <kernel/mempool_limits.h> -#include <kernel/mempool_options.h> - #include <coins.h> #include <consensus/amount.h> #include <indirectmap.h> #include <kernel/cs_main.h> -#include <kernel/mempool_entry.h> +#include <kernel/mempool_entry.h> // IWYU pragma: export +#include <kernel/mempool_limits.h> // IWYU pragma: export +#include <kernel/mempool_options.h> // IWYU pragma: export +#include <kernel/mempool_removal_reason.h> // IWYU pragma: export #include <policy/feerate.h> #include <policy/packages.h> #include <primitives/transaction.h> -#include <random.h> #include <sync.h> #include <util/epochguard.h> #include <util/hasher.h> @@ -40,9 +30,16 @@ #include <boost/multi_index/tag.hpp> #include <boost/multi_index_container.hpp> -class CBlockIndex; +#include <atomic> +#include <map> +#include <optional> +#include <set> +#include <string> +#include <string_view> +#include <utility> +#include <vector> + 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; @@ -228,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. diff --git a/src/wallet/test/util.cpp b/src/wallet/test/util.cpp index 069ab25f26..ad8613d515 100644 --- a/src/wallet/test/util.cpp +++ b/src/wallet/test/util.cpp @@ -9,6 +9,7 @@ #include <key_io.h> #include <streams.h> #include <test/util/setup_common.h> +#include <validationinterface.h> #include <wallet/context.h> #include <wallet/wallet.h> #include <wallet/walletdb.h> diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 4abf6441d2..5c297d76e4 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -21,6 +21,7 @@ #include <test/util/setup_common.h> #include <util/translation.h> #include <validation.h> +#include <validationinterface.h> #include <wallet/coincontrol.h> #include <wallet/context.h> #include <wallet/receive.h> diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 52f6e8e243..e77dd676e0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -5,51 +5,82 @@ #include <wallet/wallet.h> +#if defined(HAVE_CONFIG_H) +#include <config/bitcoin-config.h> +#endif +#include <addresstype.h> #include <blockfilter.h> #include <chain.h> +#include <coins.h> #include <common/args.h> +#include <common/settings.h> +#include <common/system.h> #include <consensus/amount.h> #include <consensus/consensus.h> #include <consensus/validation.h> #include <external_signer.h> #include <interfaces/chain.h> +#include <interfaces/handler.h> #include <interfaces/wallet.h> +#include <kernel/mempool_removal_reason.h> #include <key.h> #include <key_io.h> +#include <logging.h> #include <outputtype.h> -#include <policy/fees.h> -#include <policy/policy.h> +#include <policy/feerate.h> #include <primitives/block.h> #include <primitives/transaction.h> #include <psbt.h> +#include <pubkey.h> #include <random.h> #include <script/descriptor.h> +#include <script/interpreter.h> #include <script/script.h> +#include <script/sign.h> #include <script/signingprovider.h> #include <script/solver.h> +#include <serialize.h> +#include <span.h> +#include <streams.h> +#include <support/allocators/secure.h> +#include <support/allocators/zeroafterfree.h> #include <support/cleanse.h> -#include <txmempool.h> -#include <util/bip32.h> +#include <sync.h> +#include <tinyformat.h> +#include <uint256.h> +#include <univalue.h> #include <util/check.h> #include <util/error.h> -#include <util/fees.h> #include <util/fs.h> #include <util/fs_helpers.h> +#include <util/message.h> #include <util/moneystr.h> -#include <util/rbf.h> +#include <util/result.h> #include <util/string.h> +#include <util/time.h> #include <util/translation.h> #include <wallet/coincontrol.h> #include <wallet/context.h> +#include <wallet/crypter.h> +#include <wallet/db.h> #include <wallet/external_signer_scriptpubkeyman.h> -#include <wallet/fees.h> #include <wallet/scriptpubkeyman.h> - -#include <univalue.h> +#include <wallet/transaction.h> +#include <wallet/types.h> +#include <wallet/walletdb.h> +#include <wallet/walletutil.h> #include <algorithm> -#include <assert.h> +#include <cassert> +#include <condition_variable> +#include <exception> #include <optional> +#include <stdexcept> +#include <thread> +#include <tuple> +#include <variant> + +struct KeyOriginInfo; using interfaces::FoundBlock; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index e2be6a206a..da58c9e876 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -10,47 +10,72 @@ #include <consensus/amount.h> #include <interfaces/chain.h> #include <interfaces/handler.h> -#include <interfaces/wallet.h> +#include <kernel/cs_main.h> #include <logging.h> #include <outputtype.h> #include <policy/feerate.h> -#include <psbt.h> +#include <primitives/transaction.h> +#include <script/interpreter.h> +#include <script/script.h> +#include <support/allocators/secure.h> +#include <sync.h> #include <tinyformat.h> +#include <uint256.h> #include <util/fs.h> #include <util/hasher.h> -#include <util/message.h> #include <util/result.h> -#include <util/strencodings.h> #include <util/string.h> #include <util/time.h> #include <util/ui_change_type.h> -#include <validationinterface.h> #include <wallet/crypter.h> +#include <wallet/db.h> #include <wallet/scriptpubkeyman.h> #include <wallet/transaction.h> -#include <wallet/walletdb.h> +#include <wallet/types.h> #include <wallet/walletutil.h> -#include <algorithm> #include <atomic> +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <functional> +#include <limits> #include <map> #include <memory> #include <optional> #include <set> -#include <stdexcept> -#include <stdint.h> #include <string> -#include <utility> #include <unordered_map> +#include <utility> #include <vector> #include <boost/signals2/signal.hpp> +class CKey; +class CKeyID; +class CPubKey; +class Coin; +class SigningProvider; +enum class MemPoolRemovalReason; +enum class SigningResult; +enum class TransactionError; +namespace interfaces { +class Wallet; +} +namespace wallet { +class CWallet; +class WalletBatch; +enum class DBErrors : int; +} // namespace wallet +struct CBlockLocator; +struct CExtKey; +struct FlatSigningProvider; +struct KeyOriginInfo; +struct PartiallySignedTransaction; +struct SignatureData; using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>; -class CScript; -enum class FeeEstimateMode; struct bilingual_str; namespace wallet { @@ -119,8 +144,6 @@ constexpr CAmount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB}; static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91; class CCoinControl; -class CWalletTx; -class ReserveDestination; //! Default for -addresstype constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::BECH32}; |