From fa6e1a1e85e2e3ee6ec8fedfb5ee27f1b5bf13c4 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 30 Jul 2026 19:52:01 +0200 Subject: [PATCH 1/9] refactor: Remove static from constexpr functions in headers Those functions have no need to be static in every TU. Also, static somewhat contradicts and overwrites the inline keyword. So remove the static, and just keep constexpr (which implies inline). --- src/net_permissions.h | 2 +- src/util/string.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net_permissions.h b/src/net_permissions.h index fbaa8f1d4ca..dd4d29513e9 100644 --- a/src/net_permissions.h +++ b/src/net_permissions.h @@ -46,7 +46,7 @@ enum class NetPermissionFlags : uint32_t { Implicit = (1U << 31), All = BloomFilter | ForceRelay | Relay | NoBan | Mempool | Download | Addr, }; -static inline constexpr NetPermissionFlags operator|(NetPermissionFlags a, NetPermissionFlags b) +constexpr NetPermissionFlags operator|(NetPermissionFlags a, NetPermissionFlags b) { using t = std::underlying_type_t; return static_cast(static_cast(a) | static_cast(b)); diff --git a/src/util/string.h b/src/util/string.h index d60fff0432c..218d9928786 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -23,7 +23,7 @@ namespace util { namespace detail { template -constexpr static void CheckNumFormatSpecifiers(const char* str) +constexpr void CheckNumFormatSpecifiers(const char* str) { unsigned count_normal{0}; // Number of "normal" specifiers, like %s unsigned count_pos{0}; // Max number in positional specifier, like %8$s From 5555d5dcb55969f6b5eefcf8733b628b2f36f8c7 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 30 Jul 2026 16:33:48 +0200 Subject: [PATCH 2/9] scripted-diff: Use inline constexpr over static constexpr Both are fine and this refactor shouldn't change any behavior. However, inline constexpr will ensure each symbol has a single address across all TU, making the release binary smaller. Review note: In theory the script may also cover functions, but they were handled in the prior commit, to remove the redundant inline for them. -BEGIN VERIFY SCRIPT- sed --regexp-extended -i 's/^(static constexpr|constexpr static)\>/inline constexpr/g' $( \ git grep --extended-regexp -l '^(static constexpr|constexpr static)' -- \ '*.h' \ ':(exclude)src/crc32c' \ ':(exclude)src/ipc/libmultiprocess' \ ':(exclude)src/minisketch' \ ) -END VERIFY SCRIPT- --- src/addrman.h | 22 ++--- src/addrman_impl.h | 12 +-- src/banman.h | 4 +- src/bech32.h | 4 +- src/bip324.h | 2 +- src/chain.h | 8 +- src/common/bloom.h | 4 +- src/consensus/amount.h | 4 +- src/consensus/consensus.h | 4 +- src/consensus/validation.h | 4 +- src/i2p.h | 2 +- src/index/blockfilterindex.h | 2 +- src/index/coinstatsindex.h | 2 +- src/index/db_key.h | 4 +- src/index/txindex.h | 2 +- src/index/txospenderindex.h | 2 +- src/init.h | 4 +- src/kernel/blockmanager_opts.h | 2 +- src/kernel/caches.h | 12 +-- src/kernel/chainstatemanager_opts.h | 4 +- src/kernel/mempool_options.h | 10 +-- src/key.h | 2 +- src/logging.h | 2 +- src/mapport.h | 2 +- src/net.h | 20 ++--- src/net_processing.h | 6 +- src/netaddress.h | 16 ++-- src/node/blockstorage.h | 4 +- src/node/caches.h | 2 +- src/node/chainstatemanager_args.h | 2 +- src/node/kernel_notifications.h | 2 +- src/node/mempool_persist_args.h | 2 +- src/node/txdownloadman.h | 12 +-- src/node/txorphanage.h | 4 +- src/node/txreconciliation.h | 2 +- src/node/utxo_snapshot.h | 2 +- src/outputtype.h | 2 +- src/policy/fees/block_policy_estimator.h | 8 +- src/policy/packages.h | 4 +- src/policy/policy.h | 64 +++++++-------- src/policy/rbf.h | 2 +- src/policy/truc_policy.h | 14 ++-- src/primitives/transaction.h | 4 +- src/protocol.h | 4 +- src/psbt.h | 100 +++++++++++------------ src/qt/guiconstants.h | 8 +- src/qt/modaloverlay.h | 2 +- src/qt/optionsmodel.h | 2 +- src/qt/qrimagewidget.h | 6 +- src/rpc/blockchain.h | 2 +- src/rpc/util.h | 2 +- src/script/interpreter.h | 24 +++--- src/script/miniscript.h | 2 +- src/script/script.h | 8 +- src/script/sigcache.h | 6 +- src/serialize.h | 2 +- src/test/util/setup_common.h | 2 +- src/test/util/versionbits.h | 2 +- src/txgraph.h | 2 +- src/txmempool.h | 4 +- src/util/rbf.h | 2 +- src/util/sock.h | 2 +- src/validation.h | 6 +- src/wallet/coincontrol.h | 2 +- src/wallet/coinselection.h | 4 +- src/wallet/scriptpubkeyman.h | 2 +- src/wallet/wallet.h | 6 +- 67 files changed, 247 insertions(+), 247 deletions(-) diff --git a/src/addrman.h b/src/addrman.h index 9449c938ca1..70697f76e64 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -23,25 +23,25 @@ class NetGroupManager; /** Over how many buckets entries with tried addresses from a single group (/16 for IPv4) are spread */ -static constexpr uint32_t ADDRMAN_TRIED_BUCKETS_PER_GROUP{8}; +inline constexpr uint32_t ADDRMAN_TRIED_BUCKETS_PER_GROUP{8}; /** Over how many buckets entries with new addresses originating from a single group are spread */ -static constexpr uint32_t ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP{64}; +inline constexpr uint32_t ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP{64}; /** Maximum number of times an address can occur in the new table */ -static constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8}; +inline constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8}; /** How old addresses can maximally be */ -static constexpr auto ADDRMAN_HORIZON{30 * 24h}; +inline constexpr auto ADDRMAN_HORIZON{30 * 24h}; /** After how many failed attempts we give up on a new node */ -static constexpr int32_t ADDRMAN_RETRIES{3}; +inline constexpr int32_t ADDRMAN_RETRIES{3}; /** How many successive failures are allowed ... */ -static constexpr int32_t ADDRMAN_MAX_FAILURES{10}; +inline constexpr int32_t ADDRMAN_MAX_FAILURES{10}; /** ... in at least this duration */ -static constexpr auto ADDRMAN_MIN_FAIL{7 * 24h}; +inline constexpr auto ADDRMAN_MIN_FAIL{7 * 24h}; /** How recent a successful connection should be before we allow an address to be evicted from tried */ -static constexpr auto ADDRMAN_REPLACEMENT{4h}; +inline constexpr auto ADDRMAN_REPLACEMENT{4h}; /** The maximum number of tried addr collisions to store */ -static constexpr size_t ADDRMAN_SET_TRIED_COLLISION_SIZE{10}; +inline constexpr size_t ADDRMAN_SET_TRIED_COLLISION_SIZE{10}; /** The maximum time we'll spend trying to resolve a tried table collision */ -static constexpr auto ADDRMAN_TEST_WINDOW{40min}; +inline constexpr auto ADDRMAN_TEST_WINDOW{40min}; class InvalidAddrManVersionError : public std::ios_base::failure { @@ -53,7 +53,7 @@ class AddrManImpl; class AddrInfo; /** Default for -checkaddrman */ -static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{0}; +inline constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{0}; /** Location information for an address in AddrMan */ struct AddressPosition { diff --git a/src/addrman_impl.h b/src/addrman_impl.h index 88ee92e1b04..e6e2cab8dce 100644 --- a/src/addrman_impl.h +++ b/src/addrman_impl.h @@ -23,14 +23,14 @@ #include /** Total number of buckets for tried addresses */ -static constexpr int32_t ADDRMAN_TRIED_BUCKET_COUNT_LOG2{8}; -static constexpr int ADDRMAN_TRIED_BUCKET_COUNT{1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2}; +inline constexpr int32_t ADDRMAN_TRIED_BUCKET_COUNT_LOG2{8}; +inline constexpr int ADDRMAN_TRIED_BUCKET_COUNT{1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2}; /** Total number of buckets for new addresses */ -static constexpr int32_t ADDRMAN_NEW_BUCKET_COUNT_LOG2{10}; -static constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2}; +inline constexpr int32_t ADDRMAN_NEW_BUCKET_COUNT_LOG2{10}; +inline constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2}; /** Maximum allowed number of entries in buckets for new and tried addresses */ -static constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6}; -static constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2}; +inline constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6}; +inline constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2}; /** * User-defined type for the internally used nIds diff --git a/src/banman.h b/src/banman.h index 93149e63c5a..815e2438ae2 100644 --- a/src/banman.h +++ b/src/banman.h @@ -16,10 +16,10 @@ #include // NOTE: When adjusting this, update rpcnet:setban's help ("24h") -static constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban +inline constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban /// How often to dump banned addresses/subnets to disk. -static constexpr std::chrono::minutes DUMP_BANS_INTERVAL{15}; +inline constexpr std::chrono::minutes DUMP_BANS_INTERVAL{15}; class CClientUIInterface; class CNetAddr; diff --git a/src/bech32.h b/src/bech32.h index 9a43a58f396..f16aa8559b5 100644 --- a/src/bech32.h +++ b/src/bech32.h @@ -23,8 +23,8 @@ namespace bech32 { -static constexpr size_t CHECKSUM_SIZE = 6; -static constexpr char SEPARATOR = '1'; +inline constexpr size_t CHECKSUM_SIZE = 6; +inline constexpr char SEPARATOR = '1'; enum class Encoding { INVALID, //!< Failed decoding diff --git a/src/bip324.h b/src/bip324.h index 821cc3f759f..276f71e4a89 100644 --- a/src/bip324.h +++ b/src/bip324.h @@ -15,7 +15,7 @@ #include #include -static constexpr unsigned BIP324_SHORTIDS_IMPLEMENTED{38}; +inline constexpr unsigned BIP324_SHORTIDS_IMPLEMENTED{38}; /** The BIP324 packet cipher, encapsulating its key derivation, stream cipher, and AEAD. */ class BIP324Cipher diff --git a/src/chain.h b/src/chain.h index 7701e9262a4..1ca218458b9 100644 --- a/src/chain.h +++ b/src/chain.h @@ -26,7 +26,7 @@ * Maximum amount of time that a block timestamp is allowed to exceed the * current time before the block will be accepted. */ -static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60; +inline constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60; /** * Timestamp window used as a grace period by code that compares external @@ -34,10 +34,10 @@ static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60; * to block timestamps. This should be set at least as high as * MAX_FUTURE_BLOCK_TIME. */ -static constexpr int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME; +inline constexpr int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME; //! Init values for CBlockIndex nSequenceId when loaded from disk -static constexpr int32_t SEQ_ID_BEST_CHAIN_FROM_DISK = 0; -static constexpr int32_t SEQ_ID_INIT_FROM_DISK = 1; +inline constexpr int32_t SEQ_ID_BEST_CHAIN_FROM_DISK = 0; +inline constexpr int32_t SEQ_ID_INIT_FROM_DISK = 1; enum BlockStatus : uint32_t { //! Unused. diff --git a/src/common/bloom.h b/src/common/bloom.h index c9ed89f85e3..49d45552e45 100644 --- a/src/common/bloom.h +++ b/src/common/bloom.h @@ -15,8 +15,8 @@ class COutPoint; class CTransaction; //! 20,000 items with fp rate < 0.1% or 10,000 items and <0.0001% -static constexpr unsigned int MAX_BLOOM_FILTER_SIZE = 36000; // bytes -static constexpr unsigned int MAX_HASH_FUNCS = 50; +inline constexpr unsigned int MAX_BLOOM_FILTER_SIZE = 36000; // bytes +inline constexpr unsigned int MAX_HASH_FUNCS = 50; /** * First two bits of nFlags control how much IsRelevantAndUpdate actually updates diff --git a/src/consensus/amount.h b/src/consensus/amount.h index 2a65a83123e..684c28569fc 100644 --- a/src/consensus/amount.h +++ b/src/consensus/amount.h @@ -12,7 +12,7 @@ typedef int64_t CAmount; /** The amount of satoshis in one BTC. */ -static constexpr CAmount COIN = 100000000; +inline constexpr CAmount COIN = 100000000; /** No amount larger than this (in satoshi) is valid. * @@ -23,7 +23,7 @@ static constexpr CAmount COIN = 100000000; * critical; in unusual circumstances like a(nother) overflow bug that allowed * for the creation of coins out of thin air modification could lead to a fork. * */ -static constexpr CAmount MAX_MONEY = 21000000 * COIN; +inline constexpr CAmount MAX_MONEY = 21000000 * COIN; inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } #endif // BITCOIN_CONSENSUS_AMOUNT_H diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index 71b5fe2468d..5d22d58284d 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -25,13 +25,13 @@ static const size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * /** Flags for nSequence and nLockTime locks */ /** Interpret sequence numbers as relative lock-time constraints. */ -static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0); +inline constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0); /** * Maximum number of seconds that the timestamp of the first * block of a difficulty adjustment period is allowed to * be earlier than the last block of the previous period (BIP94). */ -static constexpr int64_t MAX_TIMEWARP = 600; +inline constexpr int64_t MAX_TIMEWARP = 600; #endif // BITCOIN_CONSENSUS_CONSENSUS_H diff --git a/src/consensus/validation.h b/src/consensus/validation.h index 37a40e767e2..b23033fce25 100644 --- a/src/consensus/validation.h +++ b/src/consensus/validation.h @@ -12,10 +12,10 @@ #include /** Index marker for when no witness commitment is present in a coinbase transaction. */ -static constexpr int NO_WITNESS_COMMITMENT{-1}; +inline constexpr int NO_WITNESS_COMMITMENT{-1}; /** Minimum size of a witness commitment structure. Defined in BIP 141. **/ -static constexpr size_t MINIMUM_WITNESS_COMMITMENT{38}; +inline constexpr size_t MINIMUM_WITNESS_COMMITMENT{38}; /** A "reason" why a transaction was invalid, suitable for determining whether the * provider of the transaction should be banned/ignored/disconnected/etc. diff --git a/src/i2p.h b/src/i2p.h index 38556d8744a..9cba32c9830 100644 --- a/src/i2p.h +++ b/src/i2p.h @@ -48,7 +48,7 @@ namespace sam { * The longest known message is ~1400 bytes, so this is high enough not to be triggered during * normal operation, yet low enough to avoid a malicious proxy from filling our memory. */ -static constexpr size_t MAX_MSG_SIZE{65536}; +inline constexpr size_t MAX_MSG_SIZE{65536}; /** * I2P SAM session. diff --git a/src/index/blockfilterindex.h b/src/index/blockfilterindex.h index 0bb4a74e125..77b87ff4765 100644 --- a/src/index/blockfilterindex.h +++ b/src/index/blockfilterindex.h @@ -28,7 +28,7 @@ enum class BlockFilterType : uint8_t; static const char* const DEFAULT_BLOCKFILTERINDEX = "0"; /** Interval between compact filter checkpoints. See BIP 157. */ -static constexpr int CFCHECKPT_INTERVAL = 1000; +inline constexpr int CFCHECKPT_INTERVAL = 1000; /** * BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of diff --git a/src/index/coinstatsindex.h b/src/index/coinstatsindex.h index 0e26fba56d9..fe61cbc7a68 100644 --- a/src/index/coinstatsindex.h +++ b/src/index/coinstatsindex.h @@ -22,7 +22,7 @@ namespace kernel { struct CCoinsStats; } -static constexpr bool DEFAULT_COINSTATSINDEX{false}; +inline constexpr bool DEFAULT_COINSTATSINDEX{false}; /** * CoinStatsIndex maintains statistics on the UTXO set. diff --git a/src/index/db_key.h b/src/index/db_key.h index 7c31f8afb8a..ffea70db2da 100644 --- a/src/index/db_key.h +++ b/src/index/db_key.h @@ -26,8 +26,8 @@ namespace index_util { * Keys for the hash index have the type [DB_BLOCK_HASH, uint256]. */ -static constexpr uint8_t DB_BLOCK_HASH{'s'}; -static constexpr uint8_t DB_BLOCK_HEIGHT{'t'}; +inline constexpr uint8_t DB_BLOCK_HASH{'s'}; +inline constexpr uint8_t DB_BLOCK_HEIGHT{'t'}; struct DBHeightKey { int height; diff --git a/src/index/txindex.h b/src/index/txindex.h index 0358e0ae49f..f35b9495767 100644 --- a/src/index/txindex.h +++ b/src/index/txindex.h @@ -16,7 +16,7 @@ namespace interfaces { class Chain; } -static constexpr bool DEFAULT_TXINDEX{false}; +inline constexpr bool DEFAULT_TXINDEX{false}; /** * TxIndex is used to look up transactions included in the blockchain by hash. diff --git a/src/index/txospenderindex.h b/src/index/txospenderindex.h index 35ca30d8b31..9a2103ca718 100644 --- a/src/index/txospenderindex.h +++ b/src/index/txospenderindex.h @@ -21,7 +21,7 @@ struct CDiskTxPos; -static constexpr bool DEFAULT_TXOSPENDERINDEX{false}; +inline constexpr bool DEFAULT_TXOSPENDERINDEX{false}; struct TxoSpender { CTransactionRef tx; diff --git a/src/init.h b/src/init.h index f3a55da35ee..ef0588a9c89 100644 --- a/src/init.h +++ b/src/init.h @@ -9,9 +9,9 @@ #include //! Default value for -daemon option -static constexpr bool DEFAULT_DAEMON = false; +inline constexpr bool DEFAULT_DAEMON = false; //! Default value for -daemonwait option -static constexpr bool DEFAULT_DAEMONWAIT = false; +inline constexpr bool DEFAULT_DAEMONWAIT = false; class ArgsManager; namespace interfaces { diff --git a/src/kernel/blockmanager_opts.h b/src/kernel/blockmanager_opts.h index 3d8af68b808..396a3ff1d93 100644 --- a/src/kernel/blockmanager_opts.h +++ b/src/kernel/blockmanager_opts.h @@ -15,7 +15,7 @@ class CChainParams; namespace kernel { -static constexpr bool DEFAULT_XOR_BLOCKSDIR{true}; +inline constexpr bool DEFAULT_XOR_BLOCKSDIR{true}; /** * An options struct for `BlockManager`, more ergonomically referred to as diff --git a/src/kernel/caches.h b/src/kernel/caches.h index 6bc10c92355..c355ed0a4bd 100644 --- a/src/kernel/caches.h +++ b/src/kernel/caches.h @@ -12,18 +12,18 @@ #include //! Minimum total database cache (bytes) -static constexpr uint64_t MIN_DBCACHE_BYTES{4_MiB}; +inline constexpr uint64_t MIN_DBCACHE_BYTES{4_MiB}; //! Maximum total database cache on current architecture (bytes) -static constexpr uint64_t MAX_DBCACHE_BYTES{sizeof(void*) == 4 ? 1_GiB : std::numeric_limits::max()}; +inline constexpr uint64_t MAX_DBCACHE_BYTES{sizeof(void*) == 4 ? 1_GiB : std::numeric_limits::max()}; //! Suggested default amount of cache reserved for the kernel (bytes) -static constexpr uint64_t DEFAULT_KERNEL_CACHE{450_MiB}; +inline constexpr uint64_t DEFAULT_KERNEL_CACHE{450_MiB}; //! Default LevelDB write batch size -static constexpr uint64_t DEFAULT_DB_CACHE_BATCH{32_MiB}; +inline constexpr uint64_t DEFAULT_DB_CACHE_BATCH{32_MiB}; //! Max memory allocated to block tree DB specific cache (bytes) -static constexpr uint64_t MAX_BLOCK_DB_CACHE{2_MiB}; +inline constexpr uint64_t MAX_BLOCK_DB_CACHE{2_MiB}; //! Max memory allocated to coin DB specific cache (bytes) -static constexpr uint64_t MAX_COINS_DB_CACHE{8_MiB}; +inline constexpr uint64_t MAX_COINS_DB_CACHE{8_MiB}; namespace kernel { struct CacheSizes { diff --git a/src/kernel/chainstatemanager_opts.h b/src/kernel/chainstatemanager_opts.h index 554d032eddc..806331caed9 100644 --- a/src/kernel/chainstatemanager_opts.h +++ b/src/kernel/chainstatemanager_opts.h @@ -21,8 +21,8 @@ class CChainParams; class ValidationSignals; -static constexpr auto DEFAULT_MAX_TIP_AGE{24h}; -static constexpr int32_t DEFAULT_PREVOUTFETCH_THREADS{8}; +inline constexpr auto DEFAULT_MAX_TIP_AGE{24h}; +inline constexpr int32_t DEFAULT_PREVOUTFETCH_THREADS{8}; namespace kernel { diff --git a/src/kernel/mempool_options.h b/src/kernel/mempool_options.h index 392c837fbbf..80b5316eee6 100644 --- a/src/kernel/mempool_options.h +++ b/src/kernel/mempool_options.h @@ -16,15 +16,15 @@ class ValidationSignals; /** Default for -maxmempool, maximum megabytes of mempool memory usage */ -static constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB{300}; +inline constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB{300}; /** Default for -maxmempool when blocksonly is set */ -static constexpr unsigned int DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB{5}; +inline constexpr unsigned int DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB{5}; /** Default for -mempoolexpiry, expiration time for mempool transactions in hours */ -static constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336}; +inline constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336}; /** Whether to fall back to legacy V1 serialization when writing mempool.dat */ -static constexpr bool DEFAULT_PERSIST_V1_DAT{false}; +inline constexpr bool DEFAULT_PERSIST_V1_DAT{false}; /** Default for -acceptnonstdtxn */ -static constexpr bool DEFAULT_ACCEPT_NON_STD_TXN{false}; +inline constexpr bool DEFAULT_ACCEPT_NON_STD_TXN{false}; namespace kernel { /** diff --git a/src/key.h b/src/key.h index 56f416ea8d0..87b130a8732 100644 --- a/src/key.h +++ b/src/key.h @@ -25,7 +25,7 @@ typedef struct secp256k1_context_struct secp256k1_context; typedef std::vector > CPrivKey; /** Size of ECDH shared secrets. */ -constexpr static size_t ECDH_SECRET_SIZE = CSHA256::OUTPUT_SIZE; +inline constexpr size_t ECDH_SECRET_SIZE = CSHA256::OUTPUT_SIZE; // Used to represent ECDH shared secret (ECDH_SECRET_SIZE bytes) using ECDHSecret = std::array; diff --git a/src/logging.h b/src/logging.h index 4bdcd0f241d..688f2b607f0 100644 --- a/src/logging.h +++ b/src/logging.h @@ -32,7 +32,7 @@ static const bool DEFAULT_LOGIPS = false; static const bool DEFAULT_LOGTIMESTAMPS = true; static const bool DEFAULT_LOGTHREADNAMES = false; static const bool DEFAULT_LOGSOURCELOCATIONS = false; -static constexpr bool DEFAULT_LOGLEVELALWAYS = false; +inline constexpr bool DEFAULT_LOGLEVELALWAYS = false; extern const char * const DEFAULT_DEBUGLOGFILE; extern bool fLogIPs; diff --git a/src/mapport.h b/src/mapport.h index 2133907badb..a33f9c609df 100644 --- a/src/mapport.h +++ b/src/mapport.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_MAPPORT_H #define BITCOIN_MAPPORT_H -static constexpr bool DEFAULT_NATPMP = true; +inline constexpr bool DEFAULT_NATPMP = true; void StartMapPort(bool enable); void InterruptMapPort(); diff --git a/src/net.h b/src/net.h index 04c26a11e5e..9911d91fb92 100644 --- a/src/net.h +++ b/src/net.h @@ -56,11 +56,11 @@ class CScheduler; struct bilingual_str; /** Time after which to disconnect, after waiting for a ping response (or inactivity). */ -static constexpr std::chrono::minutes TIMEOUT_INTERVAL{20}; +inline constexpr std::chrono::minutes TIMEOUT_INTERVAL{20}; /** Run the feeler connection loop once every 2 minutes. **/ -static constexpr auto FEELER_INTERVAL = 2min; +inline constexpr auto FEELER_INTERVAL = 2min; /** Run the extra block-relay-only connection loop once every 5 minutes. **/ -static constexpr auto EXTRA_BLOCK_RELAY_ONLY_PEER_INTERVAL = 5min; +inline constexpr auto EXTRA_BLOCK_RELAY_ONLY_PEER_INTERVAL = 5min; /** Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable). */ static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000; /** Maximum length of the user agent string in `version` message */ @@ -74,7 +74,7 @@ static const int MAX_BLOCK_RELAY_ONLY_CONNECTIONS = 2; /** Maximum number of feeler connections */ static const int MAX_FEELER_CONNECTIONS = 1; /** Maximum number of private broadcast connections */ -static constexpr size_t MAX_PRIVATE_BROADCAST_CONNECTIONS{64}; +inline constexpr size_t MAX_PRIVATE_BROADCAST_CONNECTIONS{64}; /** -listen default */ static const bool DEFAULT_LISTEN = true; /** The maximum number of peer connections to maintain. */ @@ -88,19 +88,19 @@ static const bool DEFAULT_BLOCKSONLY = false; /** -peertimeout default */ static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60; /** Default for -privatebroadcast. */ -static constexpr bool DEFAULT_PRIVATE_BROADCAST{false}; +inline constexpr bool DEFAULT_PRIVATE_BROADCAST{false}; /** Number of file descriptors required for message capture **/ static const int NUM_FDS_MESSAGE_CAPTURE = 1; /** Interval for ASMap Health Check **/ -static constexpr std::chrono::hours ASMAP_HEALTH_CHECK_INTERVAL{24}; +inline constexpr std::chrono::hours ASMAP_HEALTH_CHECK_INTERVAL{24}; -static constexpr bool DEFAULT_FORCEDNSSEED{false}; -static constexpr bool DEFAULT_DNSSEED{true}; -static constexpr bool DEFAULT_FIXEDSEEDS{true}; +inline constexpr bool DEFAULT_FORCEDNSSEED{false}; +inline constexpr bool DEFAULT_DNSSEED{true}; +inline constexpr bool DEFAULT_FIXEDSEEDS{true}; static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000; static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000; -static constexpr bool DEFAULT_V2_TRANSPORT{true}; +inline constexpr bool DEFAULT_V2_TRANSPORT{true}; typedef int64_t NodeId; diff --git a/src/net_processing.h b/src/net_processing.h index a381a6d80bc..50c329e2891 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -38,12 +38,12 @@ class Warnings; } // namespace node /** Whether transaction reconciliation protocol should be enabled by default. */ -static constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false}; +inline constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false}; /** Default number of non-mempool transactions to keep around for block reconstruction. Includes orphan, replaced, and rejected transactions. */ static const uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN{100}; /** Default maximum per-second rate for sending transaction inventory to peers. */ -static constexpr unsigned int DEFAULT_TX_SEND_RATE{14}; +inline constexpr unsigned int DEFAULT_TX_SEND_RATE{14}; static const bool DEFAULT_PEERBLOOMFILTERS = false; static const bool DEFAULT_PEERBLOCKFILTERS = false; /** Maximum number of outstanding CMPCTBLOCK requests for the same block. */ @@ -52,7 +52,7 @@ static const unsigned int MAX_CMPCTBLOCKS_INFLIGHT_PER_BLOCK = 3; * less than this number, we reached its tip. Changing this value is a protocol upgrade. */ static const unsigned int MAX_HEADERS_RESULTS = 2000; /** The compactblocks version we support. See BIP 152. */ -static constexpr uint64_t CMPCTBLOCKS_VERSION{2}; +inline constexpr uint64_t CMPCTBLOCKS_VERSION{2}; struct CNodeStateStats { int nSyncHeight = -1; diff --git a/src/netaddress.h b/src/netaddress.h index 2191da54b76..60028fd7aca 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -80,29 +80,29 @@ static const std::array INTERNAL_IN_IPV6_PREFIX{ /// All CJDNS addresses start with 0xFC. See /// https://github.com/cjdelisle/cjdns/blob/master/doc/Whitepaper.md#pulling-it-all-together -static constexpr uint8_t CJDNS_PREFIX{0xFC}; +inline constexpr uint8_t CJDNS_PREFIX{0xFC}; /// Size of IPv4 address (in bytes). -static constexpr size_t ADDR_IPV4_SIZE = 4; +inline constexpr size_t ADDR_IPV4_SIZE = 4; /// Size of IPv6 address (in bytes). -static constexpr size_t ADDR_IPV6_SIZE = 16; +inline constexpr size_t ADDR_IPV6_SIZE = 16; /// Size of TORv3 address (in bytes). This is the length of just the address /// as used in BIP155, without the checksum and the version byte. -static constexpr size_t ADDR_TORV3_SIZE = 32; +inline constexpr size_t ADDR_TORV3_SIZE = 32; /// Size of I2P address (in bytes). -static constexpr size_t ADDR_I2P_SIZE = 32; +inline constexpr size_t ADDR_I2P_SIZE = 32; /// Size of CJDNS address (in bytes). -static constexpr size_t ADDR_CJDNS_SIZE = 16; +inline constexpr size_t ADDR_CJDNS_SIZE = 16; /// Size of "internal" (NET_INTERNAL) address (in bytes). -static constexpr size_t ADDR_INTERNAL_SIZE = 10; +inline constexpr size_t ADDR_INTERNAL_SIZE = 10; /// SAM 3.1 and earlier do not support specifying ports and force the port to 0. -static constexpr uint16_t I2P_SAM31_PORT{0}; +inline constexpr uint16_t I2P_SAM31_PORT{0}; std::string OnionToString(std::span addr); diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h index 0ab595ac851..9178fb21824 100644 --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -126,10 +126,10 @@ static const unsigned int UNDOFILE_CHUNK_SIZE{1_MiB}; static const unsigned int MAX_BLOCKFILE_SIZE{128_MiB}; /** Size of header written by WriteBlock before a serialized CBlock (8 bytes) */ -static constexpr uint32_t STORAGE_HEADER_BYTES{std::tuple_size_v + sizeof(unsigned int)}; +inline constexpr uint32_t STORAGE_HEADER_BYTES{std::tuple_size_v + sizeof(unsigned int)}; /** Total overhead when writing undo data: header (8 bytes) plus checksum (32 bytes) */ -static constexpr uint32_t UNDO_DATA_DISK_OVERHEAD{STORAGE_HEADER_BYTES + uint256::size()}; +inline constexpr uint32_t UNDO_DATA_DISK_OVERHEAD{STORAGE_HEADER_BYTES + uint256::size()}; // Because validation code takes pointers to the map's CBlockIndex objects, if // we ever switch to another associative container, we need to either use a diff --git a/src/node/caches.h b/src/node/caches.h index 14056a2516f..4e8b49b37dc 100644 --- a/src/node/caches.h +++ b/src/node/caches.h @@ -15,7 +15,7 @@ class ArgsManager; //! Reserved non-dbcache memory usage. -static constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM{2_GiB}; +inline constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM{2_GiB}; namespace node { uint64_t GetDefaultDBCache(); diff --git a/src/node/chainstatemanager_args.h b/src/node/chainstatemanager_args.h index cbcbb6b47ca..9f62244ffd6 100644 --- a/src/node/chainstatemanager_args.h +++ b/src/node/chainstatemanager_args.h @@ -11,7 +11,7 @@ class ArgsManager; /** -par default (number of script-checking threads, 0 = auto) */ -static constexpr int DEFAULT_SCRIPTCHECK_THREADS{0}; +inline constexpr int DEFAULT_SCRIPTCHECK_THREADS{0}; namespace node { [[nodiscard]] util::Result ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts); diff --git a/src/node/kernel_notifications.h b/src/node/kernel_notifications.h index b152e7a476a..2f1089405dc 100644 --- a/src/node/kernel_notifications.h +++ b/src/node/kernel_notifications.h @@ -26,7 +26,7 @@ enum class Warning; namespace node { class Warnings; -static constexpr int DEFAULT_STOPATHEIGHT{0}; +inline constexpr int DEFAULT_STOPATHEIGHT{0}; //! State tracked by the KernelNotifications interface meant to be used by //! mining code, index code, RPCs, and other code sitting above the validation diff --git a/src/node/mempool_persist_args.h b/src/node/mempool_persist_args.h index 7973ec5821a..28ff297986d 100644 --- a/src/node/mempool_persist_args.h +++ b/src/node/mempool_persist_args.h @@ -15,7 +15,7 @@ namespace node { * Default for -persistmempool, indicating whether the node should attempt to * automatically load the mempool on start and save to disk on shutdown */ -static constexpr bool DEFAULT_PERSIST_MEMPOOL{true}; +inline constexpr bool DEFAULT_PERSIST_MEMPOOL{true}; bool ShouldPersistMempool(const ArgsManager& argsman); fs::path MempoolPath(const ArgsManager& argsman); diff --git a/src/node/txdownloadman.h b/src/node/txdownloadman.h index bef1d162d22..e362110212e 100644 --- a/src/node/txdownloadman.h +++ b/src/node/txdownloadman.h @@ -22,20 +22,20 @@ class TxDownloadManagerImpl; /** Maximum number of in-flight transaction requests from a peer. It is not a hard limit, but the threshold at which * point the OVERLOADED_PEER_TX_DELAY kicks in. */ -static constexpr int32_t MAX_PEER_TX_REQUEST_IN_FLIGHT = 100; +inline constexpr int32_t MAX_PEER_TX_REQUEST_IN_FLIGHT = 100; /** Maximum number of transactions to consider for requesting, per peer. It provides a reasonable DoS limit to * per-peer memory usage spent on announcements, while covering peers continuously sending INVs at the maximum * rate (by our own policy, see DEFAULT_TX_SEND_RATE) for several minutes, while not receiving * the actual transaction (from any peer) in response to requests for them. */ -static constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 5000; +inline constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 5000; /** How long to delay requesting transactions via txids, if we have wtxid-relaying peers */ -static constexpr auto TXID_RELAY_DELAY{2s}; +inline constexpr auto TXID_RELAY_DELAY{2s}; /** How long to delay requesting transactions from non-preferred peers */ -static constexpr auto NONPREF_PEER_TX_DELAY{2s}; +inline constexpr auto NONPREF_PEER_TX_DELAY{2s}; /** How long to delay requesting transactions from overloaded peers (see MAX_PEER_TX_REQUEST_IN_FLIGHT). */ -static constexpr auto OVERLOADED_PEER_TX_DELAY{2s}; +inline constexpr auto OVERLOADED_PEER_TX_DELAY{2s}; /** How long to wait before downloading a transaction from an additional peer */ -static constexpr auto GETDATA_TX_INTERVAL{60s}; +inline constexpr auto GETDATA_TX_INTERVAL{60s}; struct TxDownloadOptions { /** Read-only reference to mempool. */ const CTxMemPool& m_mempool; diff --git a/src/node/txorphanage.h b/src/node/txorphanage.h index 81c57da33e8..4411f15d0a4 100644 --- a/src/node/txorphanage.h +++ b/src/node/txorphanage.h @@ -17,10 +17,10 @@ namespace node { /** Default value for TxOrphanage::m_reserved_usage_per_peer. Helps limit the total amount of memory used by the orphanage. */ -static constexpr int64_t DEFAULT_RESERVED_ORPHAN_WEIGHT_PER_PEER{404'000}; +inline constexpr int64_t DEFAULT_RESERVED_ORPHAN_WEIGHT_PER_PEER{404'000}; /** Default value for TxOrphanage::m_max_global_latency_score. Helps limit the maximum latency for operations like * EraseForBlock and LimitOrphans. */ -static constexpr unsigned int DEFAULT_MAX_ORPHANAGE_LATENCY_SCORE{3000}; +inline constexpr unsigned int DEFAULT_MAX_ORPHANAGE_LATENCY_SCORE{3000}; /** A class to track orphan transactions (failed on TX_MISSING_INPUTS) * Since we cannot distinguish orphans from bad transactions with non-existent inputs, we heavily limit the amount of diff --git a/src/node/txreconciliation.h b/src/node/txreconciliation.h index 68deeabaf64..c9db24802ff 100644 --- a/src/node/txreconciliation.h +++ b/src/node/txreconciliation.h @@ -12,7 +12,7 @@ #include /** Supported transaction reconciliation protocol version */ -static constexpr uint32_t TXRECONCILIATION_VERSION{1}; +inline constexpr uint32_t TXRECONCILIATION_VERSION{1}; enum class ReconciliationRegisterResult { NOT_FOUND, diff --git a/src/node/utxo_snapshot.h b/src/node/utxo_snapshot.h index 482edd3e6fc..8807c27edf5 100644 --- a/src/node/utxo_snapshot.h +++ b/src/node/utxo_snapshot.h @@ -25,7 +25,7 @@ #include // UTXO set snapshot magic bytes -static constexpr std::array SNAPSHOT_MAGIC_BYTES = {'u', 't', 'x', 'o', 0xff}; +inline constexpr std::array SNAPSHOT_MAGIC_BYTES = {'u', 't', 'x', 'o', 0xff}; class Chainstate; diff --git a/src/outputtype.h b/src/outputtype.h index 4dde381b356..2b4c4d9baea 100644 --- a/src/outputtype.h +++ b/src/outputtype.h @@ -23,7 +23,7 @@ enum class OutputType { UNKNOWN, }; -static constexpr auto OUTPUT_TYPES = std::array{ +inline constexpr auto OUTPUT_TYPES = std::array{ OutputType::LEGACY, OutputType::P2SH_SEGWIT, OutputType::BECH32, diff --git a/src/policy/fees/block_policy_estimator.h b/src/policy/fees/block_policy_estimator.h index d513f15a858..a87970cd4dc 100644 --- a/src/policy/fees/block_policy_estimator.h +++ b/src/policy/fees/block_policy_estimator.h @@ -23,16 +23,16 @@ // How often to flush fee estimates to fee_estimates.dat. -static constexpr std::chrono::hours FEE_FLUSH_INTERVAL{1}; +inline constexpr std::chrono::hours FEE_FLUSH_INTERVAL{1}; /** fee_estimates.dat that are more than 60 hours (2.5 days) old will not be read, * as fee estimates are based on historical data and may be inaccurate if * network activity has changed. */ -static constexpr std::chrono::hours MAX_FILE_AGE{60}; +inline constexpr std::chrono::hours MAX_FILE_AGE{60}; // Whether we allow importing a fee_estimates file older than MAX_FILE_AGE. -static constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES{false}; +inline constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES{false}; class AutoFile; class TxConfirmStats; @@ -47,7 +47,7 @@ enum class FeeEstimateHorizon { LONG_HALFLIFE, }; -static constexpr auto ALL_FEE_ESTIMATE_HORIZONS = std::array{ +inline constexpr auto ALL_FEE_ESTIMATE_HORIZONS = std::array{ FeeEstimateHorizon::SHORT_HALFLIFE, FeeEstimateHorizon::MED_HALFLIFE, FeeEstimateHorizon::LONG_HALFLIFE, diff --git a/src/policy/packages.h b/src/policy/packages.h index 1a7e101ef46..e5704fb3796 100644 --- a/src/policy/packages.h +++ b/src/policy/packages.h @@ -16,12 +16,12 @@ #include /** Default maximum number of transactions in a package. */ -static constexpr uint32_t MAX_PACKAGE_COUNT{25}; +inline constexpr uint32_t MAX_PACKAGE_COUNT{25}; /** Default maximum total weight of transactions in a package in weight to allow for context-less checks. This must allow a superset of sigops weighted vsize limited transactions to not disallow transactions we would have otherwise accepted individually. */ -static constexpr uint32_t MAX_PACKAGE_WEIGHT = 404'000; +inline constexpr uint32_t MAX_PACKAGE_WEIGHT = 404'000; static_assert(MAX_PACKAGE_WEIGHT >= MAX_STANDARD_TX_WEIGHT); // Packages are part of a single cluster, so ensure that the package limits are diff --git a/src/policy/policy.h b/src/policy/policy.h index 13bcf4cef75..87d20486bbf 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -22,60 +22,60 @@ class CFeeRate; class CScript; /** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/ -static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT}; +inline constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT}; /** Default for -blockreservedweight **/ -static constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT{8000}; +inline constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT{8000}; /** Default sigops cost to reserve for coinbase transaction outputs when creating block templates. */ -static constexpr unsigned int DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS{400}; +inline constexpr unsigned int DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS{400}; /** This accounts for the block header, var_int encoding of the transaction count and a minimally viable * coinbase transaction. It adds an additional safety margin, because even with a thorough understanding * of block serialization, it's easy to make a costly mistake when trying to squeeze every last byte. * Setting a lower value is prevented at startup. */ -static constexpr unsigned int MINIMUM_BLOCK_RESERVED_WEIGHT{2000}; +inline constexpr unsigned int MINIMUM_BLOCK_RESERVED_WEIGHT{2000}; /** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/ -static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1}; +inline constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1}; /** The maximum weight for transactions we're willing to relay/mine */ -static constexpr int32_t MAX_STANDARD_TX_WEIGHT{400000}; +inline constexpr int32_t MAX_STANDARD_TX_WEIGHT{400000}; /** The minimum non-witness size for transactions we're willing to relay/mine: one larger than 64 */ -static constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{65}; +inline constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{65}; /** Maximum number of signature check operations in an IsStandard() P2SH script */ -static constexpr unsigned int MAX_P2SH_SIGOPS{15}; +inline constexpr unsigned int MAX_P2SH_SIGOPS{15}; /** The maximum number of sigops we're willing to relay/mine in a single tx */ -static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/5}; +inline constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/5}; /** The maximum number of potentially executed legacy signature operations in a single standard tx */ -static constexpr unsigned int MAX_TX_LEGACY_SIGOPS{2'500}; +inline constexpr unsigned int MAX_TX_LEGACY_SIGOPS{2'500}; /** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or replacement **/ -static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{100}; +inline constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{100}; /** Default for -bytespersigop */ -static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20}; +inline constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20}; /** Default for -permitbaremultisig */ -static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true}; +inline constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true}; /** The maximum number of witness stack items in a standard P2WSH script */ -static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100}; +inline constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100}; /** The maximum size in bytes of each witness stack item in a standard P2WSH script */ -static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE{80}; +inline constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE{80}; /** The maximum size in bytes of each witness stack item in a standard BIP 342 script (Taproot, leaf version 0xc0) */ -static constexpr unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE{80}; +inline constexpr unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE{80}; /** The maximum size in bytes of a standard witnessScript */ -static constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE{3600}; +inline constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE{3600}; /** The maximum size of a standard ScriptSig */ -static constexpr unsigned int MAX_STANDARD_SCRIPTSIG_SIZE{1650}; +inline constexpr unsigned int MAX_STANDARD_SCRIPTSIG_SIZE{1650}; /** Min feerate for defining dust. * Changing the dust limit changes which transactions are * standard and should be done with care and ideally rarely. It makes sense to * only increase the dust limit after prior releases were already not creating * outputs below the new threshold */ -static constexpr unsigned int DUST_RELAY_TX_FEE{3000}; +inline constexpr unsigned int DUST_RELAY_TX_FEE{3000}; /** Default for -minrelaytxfee, minimum relay fee for transactions */ -static constexpr unsigned int DEFAULT_MIN_RELAY_TX_FEE{100}; +inline constexpr unsigned int DEFAULT_MIN_RELAY_TX_FEE{100}; /** Maximum number of transactions per cluster (default) */ -static constexpr unsigned int DEFAULT_CLUSTER_LIMIT{64}; +inline constexpr unsigned int DEFAULT_CLUSTER_LIMIT{64}; /** Maximum size of cluster in virtual kilobytes */ -static constexpr unsigned int DEFAULT_CLUSTER_SIZE_LIMIT_KVB{101}; +inline constexpr unsigned int DEFAULT_CLUSTER_SIZE_LIMIT_KVB{101}; /** Default for -limitancestorcount, max number of in-mempool ancestors */ -static constexpr unsigned int DEFAULT_ANCESTOR_LIMIT{25}; +inline constexpr unsigned int DEFAULT_ANCESTOR_LIMIT{25}; /** Default for -limitdescendantcount, max number of in-mempool descendants */ -static constexpr unsigned int DEFAULT_DESCENDANT_LIMIT{25}; +inline constexpr unsigned int DEFAULT_DESCENDANT_LIMIT{25}; /** Default for -datacarrier */ static const bool DEFAULT_ACCEPT_DATACARRIER = true; /** @@ -87,12 +87,12 @@ static const unsigned int MAX_OP_RETURN_RELAY = MAX_STANDARD_TX_WEIGHT / WITNESS * ancestor and is no larger than this. Not really any reason to make this * configurable as it doesn't materially change DoS parameters. */ -static constexpr unsigned int EXTRA_DESCENDANT_TX_SIZE_LIMIT{10000}; +inline constexpr unsigned int EXTRA_DESCENDANT_TX_SIZE_LIMIT{10000}; /** * Maximum number of ephemeral dust outputs allowed. */ -static constexpr unsigned int MAX_DUST_OUTPUTS_PER_TX{1}; +inline constexpr unsigned int MAX_DUST_OUTPUTS_PER_TX{1}; /** * Mandatory script verification flags that all new transactions must comply with for @@ -101,7 +101,7 @@ static constexpr unsigned int MAX_DUST_OUTPUTS_PER_TX{1}; * Note that this does not affect consensus validity; see GetBlockScriptFlags() * for that. */ -static constexpr script_verify_flags MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY_P2SH | +inline constexpr script_verify_flags MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_NULLDUMMY | SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY | @@ -115,7 +115,7 @@ static constexpr script_verify_flags MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY * the additional (non-mandatory) rules here, to improve forwards and * backwards compatibility. */ -static constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRIPT_VERIFY_FLAGS | +inline constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRIPT_VERIFY_FLAGS | SCRIPT_VERIFY_STRICTENC | SCRIPT_VERIFY_MINIMALDATA | SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS | @@ -131,10 +131,10 @@ static constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRI SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE}; /** For convenience, standard but not mandatory verify flags. */ -static constexpr script_verify_flags STANDARD_NOT_MANDATORY_VERIFY_FLAGS{STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS}; +inline constexpr script_verify_flags STANDARD_NOT_MANDATORY_VERIFY_FLAGS{STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS}; /** Used as the flags parameter to sequence and nLocktime checks in non-consensus code. */ -static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE}; +inline constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE}; CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee); @@ -148,8 +148,8 @@ std::vector GetDust(const CTransaction& tx, CFeeRate dust_relay_rate); // Changing the default transaction version requires a two step process: first // adapting relay policy by bumping TX_MAX_STANDARD_VERSION, and then later // allowing the new transaction version in the wallet/RPC. -static constexpr decltype(CTransaction::version) TX_MIN_STANDARD_VERSION{1}; -static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3}; +inline constexpr decltype(CTransaction::version) TX_MIN_STANDARD_VERSION{1}; +inline constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3}; /** * Check for standard transaction types diff --git a/src/policy/rbf.h b/src/policy/rbf.h index 0ba646ca8d1..81769602bc0 100644 --- a/src/policy/rbf.h +++ b/src/policy/rbf.h @@ -23,7 +23,7 @@ class uint256; /** Maximum number of unique clusters that can be affected by an RBF (Rule #5); * see GetEntriesForConflicts() */ -static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES{100}; +inline constexpr uint32_t MAX_REPLACEMENT_CANDIDATES{100}; /** The rbf state of unconfirmed transactions */ enum class RBFTransactionState { diff --git a/src/policy/truc_policy.h b/src/policy/truc_policy.h index b6fe6e1242b..137f54b88de 100644 --- a/src/policy/truc_policy.h +++ b/src/policy/truc_policy.h @@ -17,21 +17,21 @@ // This module enforces rules for BIP 431 TRUC transactions which help make // RBF abilities more robust. A transaction with version=3 is treated as TRUC. -static constexpr decltype(CTransaction::version) TRUC_VERSION{3}; +inline constexpr decltype(CTransaction::version) TRUC_VERSION{3}; // TRUC only allows 1 parent and 1 child when unconfirmed. This translates to a descendant set size // of 2 and ancestor set size of 2. /** Maximum number of transactions including an unconfirmed tx and its descendants. */ -static constexpr unsigned int TRUC_DESCENDANT_LIMIT{2}; +inline constexpr unsigned int TRUC_DESCENDANT_LIMIT{2}; /** Maximum number of transactions including a TRUC tx and all its mempool ancestors. */ -static constexpr unsigned int TRUC_ANCESTOR_LIMIT{2}; +inline constexpr unsigned int TRUC_ANCESTOR_LIMIT{2}; /** Maximum sigop-adjusted virtual size of all v3 transactions. */ -static constexpr int64_t TRUC_MAX_VSIZE{10000}; -static constexpr int64_t TRUC_MAX_WEIGHT{TRUC_MAX_VSIZE * WITNESS_SCALE_FACTOR}; +inline constexpr int64_t TRUC_MAX_VSIZE{10000}; +inline constexpr int64_t TRUC_MAX_WEIGHT{TRUC_MAX_VSIZE * WITNESS_SCALE_FACTOR}; /** Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed TRUC transaction. */ -static constexpr int64_t TRUC_CHILD_MAX_VSIZE{1000}; -static constexpr int64_t TRUC_CHILD_MAX_WEIGHT{TRUC_CHILD_MAX_VSIZE * WITNESS_SCALE_FACTOR}; +inline constexpr int64_t TRUC_CHILD_MAX_VSIZE{1000}; +inline constexpr int64_t TRUC_CHILD_MAX_WEIGHT{TRUC_CHILD_MAX_VSIZE * WITNESS_SCALE_FACTOR}; // These limits are within the default cluster limits. static_assert(TRUC_MAX_VSIZE + TRUC_CHILD_MAX_VSIZE <= DEFAULT_CLUSTER_SIZE_LIMIT_KVB * 1000); diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 17fea5b46b5..9fc8923fba7 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -177,8 +177,8 @@ struct TransactionSerParams { const bool allow_witness; SER_PARAMS_OPFUNC }; -static constexpr TransactionSerParams TX_WITH_WITNESS{.allow_witness = true}; -static constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false}; +inline constexpr TransactionSerParams TX_WITH_WITNESS{.allow_witness = true}; +inline constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false}; /** * Basic transaction serialization format: diff --git a/src/protocol.h b/src/protocol.h index a15a3aa60af..a53f15e455a 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -310,8 +310,8 @@ inline const std::array ALL_NET_MESSAGE_TYPES{std::to_array({ NetMsgType::FEATURE, })}; -static constexpr size_t MAX_FEATUREID_LENGTH{80}; -static constexpr size_t MAX_FEATUREDATA_LENGTH{512}; +inline constexpr size_t MAX_FEATUREID_LENGTH{80}; +inline constexpr size_t MAX_FEATUREDATA_LENGTH{512}; namespace NetMsgFeature { //inline constexpr std::string_view FOO{"BIP-FOO"}; diff --git a/src/psbt.h b/src/psbt.h index b0177a3e555..233a4fb673d 100644 --- a/src/psbt.h +++ b/src/psbt.h @@ -29,71 +29,71 @@ enum class TransactionError; using common::PSBTError; // Magic bytes -static constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff}; +inline constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff}; // Global types -static constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX = 0x00; -static constexpr uint8_t PSBT_GLOBAL_XPUB = 0x01; -static constexpr uint8_t PSBT_GLOBAL_TX_VERSION = 0x02; -static constexpr uint8_t PSBT_GLOBAL_FALLBACK_LOCKTIME = 0x03; -static constexpr uint8_t PSBT_GLOBAL_INPUT_COUNT = 0x04; -static constexpr uint8_t PSBT_GLOBAL_OUTPUT_COUNT = 0x05; -static constexpr uint8_t PSBT_GLOBAL_TX_MODIFIABLE = 0x06; -static constexpr uint8_t PSBT_GLOBAL_VERSION = 0xFB; -static constexpr uint8_t PSBT_GLOBAL_PROPRIETARY = 0xFC; +inline constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX = 0x00; +inline constexpr uint8_t PSBT_GLOBAL_XPUB = 0x01; +inline constexpr uint8_t PSBT_GLOBAL_TX_VERSION = 0x02; +inline constexpr uint8_t PSBT_GLOBAL_FALLBACK_LOCKTIME = 0x03; +inline constexpr uint8_t PSBT_GLOBAL_INPUT_COUNT = 0x04; +inline constexpr uint8_t PSBT_GLOBAL_OUTPUT_COUNT = 0x05; +inline constexpr uint8_t PSBT_GLOBAL_TX_MODIFIABLE = 0x06; +inline constexpr uint8_t PSBT_GLOBAL_VERSION = 0xFB; +inline constexpr uint8_t PSBT_GLOBAL_PROPRIETARY = 0xFC; // Input types -static constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO = 0x00; -static constexpr uint8_t PSBT_IN_WITNESS_UTXO = 0x01; -static constexpr uint8_t PSBT_IN_PARTIAL_SIG = 0x02; -static constexpr uint8_t PSBT_IN_SIGHASH = 0x03; -static constexpr uint8_t PSBT_IN_REDEEMSCRIPT = 0x04; -static constexpr uint8_t PSBT_IN_WITNESSSCRIPT = 0x05; -static constexpr uint8_t PSBT_IN_BIP32_DERIVATION = 0x06; -static constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07; -static constexpr uint8_t PSBT_IN_SCRIPTWITNESS = 0x08; -static constexpr uint8_t PSBT_IN_RIPEMD160 = 0x0A; -static constexpr uint8_t PSBT_IN_SHA256 = 0x0B; -static constexpr uint8_t PSBT_IN_HASH160 = 0x0C; -static constexpr uint8_t PSBT_IN_HASH256 = 0x0D; -static constexpr uint8_t PSBT_IN_PREVIOUS_TXID = 0x0e; -static constexpr uint8_t PSBT_IN_OUTPUT_INDEX = 0x0f; -static constexpr uint8_t PSBT_IN_SEQUENCE = 0x10; -static constexpr uint8_t PSBT_IN_REQUIRED_TIME_LOCKTIME = 0x11; -static constexpr uint8_t PSBT_IN_REQUIRED_HEIGHT_LOCKTIME = 0x12; -static constexpr uint8_t PSBT_IN_TAP_KEY_SIG = 0x13; -static constexpr uint8_t PSBT_IN_TAP_SCRIPT_SIG = 0x14; -static constexpr uint8_t PSBT_IN_TAP_LEAF_SCRIPT = 0x15; -static constexpr uint8_t PSBT_IN_TAP_BIP32_DERIVATION = 0x16; -static constexpr uint8_t PSBT_IN_TAP_INTERNAL_KEY = 0x17; -static constexpr uint8_t PSBT_IN_TAP_MERKLE_ROOT = 0x18; -static constexpr uint8_t PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS = 0x1a; -static constexpr uint8_t PSBT_IN_MUSIG2_PUB_NONCE = 0x1b; -static constexpr uint8_t PSBT_IN_MUSIG2_PARTIAL_SIG = 0x1c; -static constexpr uint8_t PSBT_IN_PROPRIETARY = 0xFC; +inline constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO = 0x00; +inline constexpr uint8_t PSBT_IN_WITNESS_UTXO = 0x01; +inline constexpr uint8_t PSBT_IN_PARTIAL_SIG = 0x02; +inline constexpr uint8_t PSBT_IN_SIGHASH = 0x03; +inline constexpr uint8_t PSBT_IN_REDEEMSCRIPT = 0x04; +inline constexpr uint8_t PSBT_IN_WITNESSSCRIPT = 0x05; +inline constexpr uint8_t PSBT_IN_BIP32_DERIVATION = 0x06; +inline constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07; +inline constexpr uint8_t PSBT_IN_SCRIPTWITNESS = 0x08; +inline constexpr uint8_t PSBT_IN_RIPEMD160 = 0x0A; +inline constexpr uint8_t PSBT_IN_SHA256 = 0x0B; +inline constexpr uint8_t PSBT_IN_HASH160 = 0x0C; +inline constexpr uint8_t PSBT_IN_HASH256 = 0x0D; +inline constexpr uint8_t PSBT_IN_PREVIOUS_TXID = 0x0e; +inline constexpr uint8_t PSBT_IN_OUTPUT_INDEX = 0x0f; +inline constexpr uint8_t PSBT_IN_SEQUENCE = 0x10; +inline constexpr uint8_t PSBT_IN_REQUIRED_TIME_LOCKTIME = 0x11; +inline constexpr uint8_t PSBT_IN_REQUIRED_HEIGHT_LOCKTIME = 0x12; +inline constexpr uint8_t PSBT_IN_TAP_KEY_SIG = 0x13; +inline constexpr uint8_t PSBT_IN_TAP_SCRIPT_SIG = 0x14; +inline constexpr uint8_t PSBT_IN_TAP_LEAF_SCRIPT = 0x15; +inline constexpr uint8_t PSBT_IN_TAP_BIP32_DERIVATION = 0x16; +inline constexpr uint8_t PSBT_IN_TAP_INTERNAL_KEY = 0x17; +inline constexpr uint8_t PSBT_IN_TAP_MERKLE_ROOT = 0x18; +inline constexpr uint8_t PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS = 0x1a; +inline constexpr uint8_t PSBT_IN_MUSIG2_PUB_NONCE = 0x1b; +inline constexpr uint8_t PSBT_IN_MUSIG2_PARTIAL_SIG = 0x1c; +inline constexpr uint8_t PSBT_IN_PROPRIETARY = 0xFC; // Output types -static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00; -static constexpr uint8_t PSBT_OUT_WITNESSSCRIPT = 0x01; -static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02; -static constexpr uint8_t PSBT_OUT_AMOUNT = 0x03; -static constexpr uint8_t PSBT_OUT_SCRIPT = 0x04; -static constexpr uint8_t PSBT_OUT_TAP_INTERNAL_KEY = 0x05; -static constexpr uint8_t PSBT_OUT_TAP_TREE = 0x06; -static constexpr uint8_t PSBT_OUT_TAP_BIP32_DERIVATION = 0x07; -static constexpr uint8_t PSBT_OUT_MUSIG2_PARTICIPANT_PUBKEYS = 0x08; -static constexpr uint8_t PSBT_OUT_PROPRIETARY = 0xFC; +inline constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00; +inline constexpr uint8_t PSBT_OUT_WITNESSSCRIPT = 0x01; +inline constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02; +inline constexpr uint8_t PSBT_OUT_AMOUNT = 0x03; +inline constexpr uint8_t PSBT_OUT_SCRIPT = 0x04; +inline constexpr uint8_t PSBT_OUT_TAP_INTERNAL_KEY = 0x05; +inline constexpr uint8_t PSBT_OUT_TAP_TREE = 0x06; +inline constexpr uint8_t PSBT_OUT_TAP_BIP32_DERIVATION = 0x07; +inline constexpr uint8_t PSBT_OUT_MUSIG2_PARTICIPANT_PUBKEYS = 0x08; +inline constexpr uint8_t PSBT_OUT_PROPRIETARY = 0xFC; // The separator is 0x00. Reading this in means that the unserializer can interpret it // as a 0 length key which indicates that this is the separator. The separator has no value. -static constexpr uint8_t PSBT_SEPARATOR = 0x00; +inline constexpr uint8_t PSBT_SEPARATOR = 0x00; // BIP 174 does not specify a maximum file size, but we set a limit anyway // to prevent reading a stream indefinitely and running out of memory. const std::streamsize MAX_FILE_SIZE_PSBT = 100000000; // 100 MB // PSBT version number -static constexpr uint32_t PSBT_HIGHEST_VERSION = 2; +inline constexpr uint32_t PSBT_HIGHEST_VERSION = 2; /** A structure for PSBT proprietary types */ struct PSBTProprietary diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index a3b8cb9d9ce..79d5b577e3b 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -11,10 +11,10 @@ using namespace std::chrono_literals; /* A delay between model updates */ -static constexpr auto MODEL_UPDATE_DELAY{250ms}; +inline constexpr auto MODEL_UPDATE_DELAY{250ms}; /* A delay between shutdown pollings */ -static constexpr auto SHUTDOWN_POLLING_DELAY{200ms}; +inline constexpr auto SHUTDOWN_POLLING_DELAY{200ms}; /* AskPassphraseDialog -- Maximum passphrase length */ static const int MAX_PASSPHRASE_SIZE = 1024; @@ -55,9 +55,9 @@ static const int TOOLTIP_WRAP_THRESHOLD = 80; #define QAPP_APP_NAME_REGTEST "Bitcoin-Qt-regtest" /* One gigabyte (GB) in bytes */ -static constexpr uint64_t GB_BYTES{1000000000}; +inline constexpr uint64_t GB_BYTES{1000000000}; // Default prune target displayed in GUI. -static constexpr int DEFAULT_PRUNE_TARGET_GB{2}; +inline constexpr int DEFAULT_PRUNE_TARGET_GB{2}; #endif // BITCOIN_QT_GUICONSTANTS_H diff --git a/src/qt/modaloverlay.h b/src/qt/modaloverlay.h index 7c4b7a4b85c..f434aaadc1e 100644 --- a/src/qt/modaloverlay.h +++ b/src/qt/modaloverlay.h @@ -10,7 +10,7 @@ #include //! The required delta of headers to the estimated number of available headers until we show the IBD progress -static constexpr int HEADER_HEIGHT_DELTA_SYNC = 24; +inline constexpr int HEADER_HEIGHT_DELTA_SYNC = 24; namespace Ui { class ModalOverlay; diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index feef00a3cf4..9d10694718b 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -22,7 +22,7 @@ class Node; } extern const char *DEFAULT_GUI_PROXY_HOST; -static constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050; +inline constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050; /** * Convert configured prune target MiB to displayed GB. Round up to avoid underestimating max disk usage. diff --git a/src/qt/qrimagewidget.h b/src/qt/qrimagewidget.h index 844a6e031ab..b65b2b7a0dc 100644 --- a/src/qt/qrimagewidget.h +++ b/src/qt/qrimagewidget.h @@ -12,9 +12,9 @@ static const int MAX_URI_LENGTH = 255; /* Size of exported QR Code image */ -static constexpr int QR_IMAGE_SIZE = 300; -static constexpr int QR_IMAGE_TEXT_MARGIN = 10; -static constexpr int QR_IMAGE_MARGIN = 2 * QR_IMAGE_TEXT_MARGIN; +inline constexpr int QR_IMAGE_SIZE = 300; +inline constexpr int QR_IMAGE_TEXT_MARGIN = 10; +inline constexpr int QR_IMAGE_MARGIN = 2 * QR_IMAGE_TEXT_MARGIN; QT_BEGIN_NAMESPACE class QMenu; diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index 45f62c628b0..1b7c34d945d 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -27,7 +27,7 @@ class BlockManager; struct NodeContext; } // namespace node -static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5; +inline constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5; /** * Get the difficulty of the net wrt to the given block index. diff --git a/src/rpc/util.h b/src/rpc/util.h index 143abbba5f3..3122bb7dbc5 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -43,7 +43,7 @@ namespace node { enum class TransactionError; } // namespace node -static constexpr bool DEFAULT_RPC_DOC_CHECK{ +inline constexpr bool DEFAULT_RPC_DOC_CHECK{ #ifdef RPC_DOC_CHECK true #else diff --git a/src/script/interpreter.h b/src/script/interpreter.h index ff63a73f0fc..47d9bfb09c9 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -45,7 +45,7 @@ enum * flags (A | B) is a subset of the acceptable scripts under flag (A). */ -static constexpr script_verify_flags SCRIPT_VERIFY_NONE{0}; +inline constexpr script_verify_flags SCRIPT_VERIFY_NONE{0}; enum class script_verify_flag_name : uint8_t { // Evaluate P2SH subscripts (BIP16). @@ -152,12 +152,12 @@ enum class script_verify_flag_name : uint8_t { }; using enum script_verify_flag_name; -static constexpr int MAX_SCRIPT_VERIFY_FLAGS_BITS = static_cast(SCRIPT_VERIFY_END_MARKER); +inline constexpr int MAX_SCRIPT_VERIFY_FLAGS_BITS = static_cast(SCRIPT_VERIFY_END_MARKER); // assert there is still a spare bit static_assert(0 < MAX_SCRIPT_VERIFY_FLAGS_BITS && MAX_SCRIPT_VERIFY_FLAGS_BITS <= 63); -static constexpr script_verify_flags::value_type MAX_SCRIPT_VERIFY_FLAGS = ((script_verify_flags::value_type{1} << MAX_SCRIPT_VERIFY_FLAGS_BITS) - 1); +inline constexpr script_verify_flags::value_type MAX_SCRIPT_VERIFY_FLAGS = ((script_verify_flags::value_type{1} << MAX_SCRIPT_VERIFY_FLAGS_BITS) - 1); bool CheckSignatureEncoding(const std::vector &vchSig, script_verify_flags flags, ScriptError* serror); @@ -235,16 +235,16 @@ struct ScriptExecutionData }; /** Signature hash sizes */ -static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE = 32; -static constexpr size_t WITNESS_V0_KEYHASH_SIZE = 20; -static constexpr size_t WITNESS_V1_TAPROOT_SIZE = 32; +inline constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE = 32; +inline constexpr size_t WITNESS_V0_KEYHASH_SIZE = 20; +inline constexpr size_t WITNESS_V1_TAPROOT_SIZE = 32; -static constexpr uint8_t TAPROOT_LEAF_MASK = 0xfe; -static constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT = 0xc0; -static constexpr size_t TAPROOT_CONTROL_BASE_SIZE = 33; -static constexpr size_t TAPROOT_CONTROL_NODE_SIZE = 32; -static constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT = 128; -static constexpr size_t TAPROOT_CONTROL_MAX_SIZE = TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * TAPROOT_CONTROL_MAX_NODE_COUNT; +inline constexpr uint8_t TAPROOT_LEAF_MASK = 0xfe; +inline constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT = 0xc0; +inline constexpr size_t TAPROOT_CONTROL_BASE_SIZE = 33; +inline constexpr size_t TAPROOT_CONTROL_NODE_SIZE = 32; +inline constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT = 128; +inline constexpr size_t TAPROOT_CONTROL_MAX_SIZE = TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * TAPROOT_CONTROL_MAX_NODE_COUNT; extern const HashWriter HASHER_TAPSIGHASH; //!< Hasher with tag "TapSighash" pre-fed to it. extern const HashWriter HASHER_TAPLEAF; //!< Hasher with tag "TapLeaf" pre-fed to it. diff --git a/src/script/miniscript.h b/src/script/miniscript.h index 4e8beb19e6b..f0867acf3ee 100644 --- a/src/script/miniscript.h +++ b/src/script/miniscript.h @@ -268,7 +268,7 @@ constexpr bool IsTapscript(MiniscriptContext ms_ctx) namespace internal { //! The maximum size of a witness item for a Miniscript under Tapscript context. (A BIP340 signature with a sighash type byte.) -static constexpr uint32_t MAX_TAPMINISCRIPT_STACK_ELEM_SIZE{65}; +inline constexpr uint32_t MAX_TAPMINISCRIPT_STACK_ELEM_SIZE{65}; //! version + nLockTime constexpr uint32_t TX_OVERHEAD{4 + 4}; diff --git a/src/script/script.h b/src/script/script.h index e23ad440490..5590ecce215 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -35,7 +35,7 @@ static const int MAX_OPS_PER_SCRIPT = 201; static const int MAX_PUBKEYS_PER_MULTISIG = 20; /** The limit of keys in OP_CHECKSIGADD-based scripts. It is due to the stack limit in BIP342. */ -static constexpr unsigned int MAX_PUBKEYS_PER_MULTI_A = 999; +inline constexpr unsigned int MAX_PUBKEYS_PER_MULTI_A = 999; // Maximum script length in bytes static const int MAX_SCRIPT_SIZE = 10000; @@ -56,13 +56,13 @@ static const uint32_t LOCKTIME_MAX = 0xFFFFFFFFU; // Tag for input annex. If there are at least two witness elements for a transaction input, // and the first byte of the last element is 0x50, this last element is called annex, and // has meanings independent of the script -static constexpr unsigned int ANNEX_TAG = 0x50; +inline constexpr unsigned int ANNEX_TAG = 0x50; // Validation weight per passing signature (Tapscript only, see BIP 342). -static constexpr int64_t VALIDATION_WEIGHT_PER_SIGOP_PASSED{50}; +inline constexpr int64_t VALIDATION_WEIGHT_PER_SIGOP_PASSED{50}; // How much weight budget is added to the witness size (Tapscript only, see BIP 342). -static constexpr int64_t VALIDATION_WEIGHT_OFFSET{50}; +inline constexpr int64_t VALIDATION_WEIGHT_OFFSET{50}; template std::vector ToByteVector(const T& in) diff --git a/src/script/sigcache.h b/src/script/sigcache.h index 092bbf3e8e1..d11c6ad316d 100644 --- a/src/script/sigcache.h +++ b/src/script/sigcache.h @@ -28,9 +28,9 @@ class XOnlyPubKey; // DoS prevention: limit cache size to 32MiB (over 1000000 entries on 64-bit // systems). Due to how we count cache size, actual memory usage is slightly // more (~32.25 MiB) -static constexpr size_t DEFAULT_VALIDATION_CACHE_BYTES{32_MiB}; -static constexpr size_t DEFAULT_SIGNATURE_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2}; -static constexpr size_t DEFAULT_SCRIPT_EXECUTION_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2}; +inline constexpr size_t DEFAULT_VALIDATION_CACHE_BYTES{32_MiB}; +inline constexpr size_t DEFAULT_SIGNATURE_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2}; +inline constexpr size_t DEFAULT_SCRIPT_EXECUTION_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2}; static_assert(DEFAULT_VALIDATION_CACHE_BYTES == DEFAULT_SIGNATURE_CACHE_BYTES + DEFAULT_SCRIPT_EXECUTION_CACHE_BYTES); /** diff --git a/src/serialize.h b/src/serialize.h index 5d38a510076..5d8b4109b11 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -32,7 +32,7 @@ * The maximum size of a serialized object in bytes or number of elements * (for eg vectors) when the size is encoded as CompactSize. */ -static constexpr uint64_t MAX_SIZE = 0x02000000; +inline constexpr uint64_t MAX_SIZE = 0x02000000; /** Maximum amount of memory (in bytes) to allocate at once when deserializing vectors. */ static const unsigned int MAX_VECTOR_ALLOCATE = 5000000; diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 7818224e554..a1ac01f2075 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -38,7 +38,7 @@ extern const std::function()> G_TEST_COMMAND_LINE_ARGUM /** Retrieve the unit test name. */ extern const std::function G_TEST_GET_FULL_NAME; -static constexpr CAmount CENT{1000000}; +inline constexpr CAmount CENT{1000000}; /** Register common test args. Shared across binaries that rely on the test framework. */ void SetupCommonTestArgs(ArgsManager& argsman); diff --git a/src/test/util/versionbits.h b/src/test/util/versionbits.h index 478b7882fab..c1f7e458435 100644 --- a/src/test/util/versionbits.h +++ b/src/test/util/versionbits.h @@ -8,6 +8,6 @@ #include /** Total possible bits available for versionbits per original BIP 9 specification */ -static constexpr int VERSIONBITS_MAX_NUM_BITS{29}; +inline constexpr int VERSIONBITS_MAX_NUM_BITS{29}; #endif // BITCOIN_TEST_UTIL_VERSIONBITS_H diff --git a/src/txgraph.h b/src/txgraph.h index f76915c8d18..174ff560d16 100644 --- a/src/txgraph.h +++ b/src/txgraph.h @@ -15,7 +15,7 @@ #ifndef BITCOIN_TXGRAPH_H #define BITCOIN_TXGRAPH_H -static constexpr unsigned MAX_CLUSTER_COUNT_LIMIT{64}; +inline constexpr unsigned MAX_CLUSTER_COUNT_LIMIT{64}; /** Data structure to encapsulate fees, sizes, and dependencies for a set of transactions. * diff --git a/src/txmempool.h b/src/txmempool.h index eb7e44a8c68..bf033474b02 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -51,11 +51,11 @@ static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF; /** How much linearization cost required for TxGraph clusters to have * "acceptable" quality, if they cannot be optimally linearized with less cost. */ -static constexpr uint64_t ACCEPTABLE_COST = 75'000; +inline constexpr uint64_t ACCEPTABLE_COST = 75'000; /** How much work we ask TxGraph to do after a mempool change occurs (either * due to a changeset being applied, a new block being found, or a reorg). */ -static constexpr uint64_t POST_CHANGE_COST = 5 * ACCEPTABLE_COST; +inline constexpr uint64_t POST_CHANGE_COST = 5 * ACCEPTABLE_COST; /** * Test whether the LockPoints height and time are still valid on the current chain diff --git a/src/util/rbf.h b/src/util/rbf.h index 387ca5bd66c..44fa3ec9a55 100644 --- a/src/util/rbf.h +++ b/src/util/rbf.h @@ -9,7 +9,7 @@ class CTransaction; -static constexpr uint32_t MAX_BIP125_RBF_SEQUENCE{0xfffffffd}; +inline constexpr uint32_t MAX_BIP125_RBF_SEQUENCE{0xfffffffd}; /** Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee, * according to BIP 125. Allow opt-out of transaction replacement by setting nSequence > diff --git a/src/util/sock.h b/src/util/sock.h index 97da86dfd65..66243970452 100644 --- a/src/util/sock.h +++ b/src/util/sock.h @@ -21,7 +21,7 @@ class CThreadInterrupt; * Maximum time to wait for I/O readiness. * It will take up until this time to break off in case of an interruption. */ -static constexpr auto MAX_WAIT_FOR_IO = 1s; +inline constexpr auto MAX_WAIT_FOR_IO = 1s; inline bool IOErrorIsPermanent(int err) { diff --git a/src/validation.h b/src/validation.h index d89ad3539e4..52480e14018 100644 --- a/src/validation.h +++ b/src/validation.h @@ -75,7 +75,7 @@ class SignalInterrupt; /** Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ActiveChain().Tip() will not be pruned. */ static const unsigned int MIN_BLOCKS_TO_KEEP = 288; static const signed int DEFAULT_CHECKBLOCKS = 6; -static constexpr int DEFAULT_CHECKLEVEL{3}; +inline constexpr int DEFAULT_CHECKLEVEL{3}; // Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev???.dat) // At 1MB per block, 288 blocks = 288MB. // Add 15% for Undo data = 331MB @@ -87,10 +87,10 @@ static constexpr int DEFAULT_CHECKLEVEL{3}; static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES{550_MiB}; /** Maximum number of dedicated script-checking threads allowed */ -static constexpr int MAX_SCRIPTCHECK_THREADS{15}; +inline constexpr int MAX_SCRIPTCHECK_THREADS{15}; /** Maximum number of dedicated threads allowed for prefetching block input prevouts */ -static constexpr int32_t MAX_PREVOUTFETCH_THREADS{16}; +inline constexpr int32_t MAX_PREVOUTFETCH_THREADS{16}; /** Current sync state passed to tip changed callbacks. */ enum class SynchronizationState { diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h index f329de688a7..f67649f7e44 100644 --- a/src/wallet/coincontrol.h +++ b/src/wallet/coincontrol.h @@ -25,7 +25,7 @@ const int DEFAULT_MAX_DEPTH = 9999999; const int DEFAULT_WALLET_TX_VERSION = CTransaction::CURRENT_VERSION; //! Default for -avoidpartialspends -static constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false; +inline constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false; class PreselectedInput { diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 2457cf95ee2..cfa866db55d 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -20,9 +20,9 @@ namespace wallet { //! lower bound for randomly-chosen target change amount -static constexpr CAmount CHANGE_LOWER{50000}; +inline constexpr CAmount CHANGE_LOWER{50000}; //! upper bound for randomly-chosen target change amount -static constexpr CAmount CHANGE_UPPER{1000000}; +inline constexpr CAmount CHANGE_UPPER{1000000}; /** A UTXO under consideration for use in funding a new transaction. */ struct COutput { diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 6cebae052bf..ccf8ae10d34 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -58,7 +58,7 @@ public: }; //! Constant representing an unknown spkm creation time -static constexpr int64_t UNKNOWN_TIME = std::numeric_limits::max(); +inline constexpr int64_t UNKNOWN_TIME = std::numeric_limits::max(); //! Default for -keypool static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 9b1bb8b6ddc..6d26b386bea 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -140,14 +140,14 @@ constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100}; //! -maxtxfee will warn if called with a higher fee than this amount (in satoshis) constexpr CAmount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB}; //! Pre-calculated constants for input size estimation in *virtual size* -static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91; +inline constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91; class CCoinControl; //! Default for -addresstype constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::BECH32}; -static constexpr uint64_t KNOWN_WALLET_FLAGS = +inline constexpr uint64_t KNOWN_WALLET_FLAGS = WALLET_FLAG_AVOID_REUSE | WALLET_FLAG_BLANK_WALLET | WALLET_FLAG_KEY_ORIGIN_METADATA @@ -156,7 +156,7 @@ static constexpr uint64_t KNOWN_WALLET_FLAGS = | WALLET_FLAG_DESCRIPTORS | WALLET_FLAG_EXTERNAL_SIGNER; -static constexpr uint64_t MUTABLE_WALLET_FLAGS = +inline constexpr uint64_t MUTABLE_WALLET_FLAGS = WALLET_FLAG_AVOID_REUSE; static const std::map WALLET_FLAG_TO_STRING{ From faedb52583e1c1eb6feb9cc03f4caf0bf52a8555 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 31 Jul 2026 10:30:05 +0200 Subject: [PATCH 3/9] refactor: Make CFeeRate(integral) ctor constexpr This is required for the next commit. Also, in a test, use `inline constexpr` for an `auto` type, which is also needed for the next commit, which hard-codes a list of types for conversion. --- src/policy/feerate.h | 2 +- src/test/util/chainstate.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/policy/feerate.h b/src/policy/feerate.h index 8f13f8d0dca..c397a5c23ac 100644 --- a/src/policy/feerate.h +++ b/src/policy/feerate.h @@ -38,7 +38,7 @@ public: /** Fee rate of 0 satoshis per 0 vB */ CFeeRate() = default; template // Disallow silent float -> int conversion - explicit CFeeRate(const I m_feerate_kvb) : m_feerate(FeePerVSize(m_feerate_kvb, 1000)) {} + explicit constexpr CFeeRate(const I m_feerate_kvb) : m_feerate(FeePerVSize(m_feerate_kvb, 1000)) {} /** * Construct a fee rate from a fee in satoshis and a vsize in vB. diff --git a/src/test/util/chainstate.h b/src/test/util/chainstate.h index aeec14ccb19..7846726d360 100644 --- a/src/test/util/chainstate.h +++ b/src/test/util/chainstate.h @@ -17,7 +17,7 @@ #include -const auto NoMalleation = [](AutoFile& file, node::SnapshotMetadata& meta){}; +inline constexpr auto NoMalleation = [](AutoFile& file, node::SnapshotMetadata& meta){}; /** * Create and activate a UTXO snapshot, optionally providing a function to From fad753611b5c074f38120fd9c1a87e37cc44bf6a Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 31 Jul 2026 07:29:00 +0200 Subject: [PATCH 4/9] scripted-diff: Use inline constexpr over (static) const Both are fine and this refactor shouldn't change any behavior. However, inline constexpr will ensure each symbol has a single address across all TU, making the release binary smaller. Note, a follow-up commit will deal with string literals (const char*) and other static const, which can not be constexpr (e.g. std::vector). -BEGIN VERIFY SCRIPT- # Limit to types that can be constexpr type='bool|CAmount|size_t|((signed|unsigned) )?int|u?int[0-9]+_t|std::array|DatabaseFormat|CFeeRate|std::streamsize' sed -i --regexp-extended "s/^(static )?const (${type})\>/inline constexpr \2/" $( \ git grep -l --extended-regexp "^(static )?const " -- \ '*.h' \ ':(exclude)src/leveldb' \ ':(exclude)src/secp256k1' \ ) -END VERIFY SCRIPT- --- src/chainparamsseeds.h | 8 ++++---- src/clientversion.h | 2 +- src/consensus/consensus.h | 14 ++++++------- src/crypto/aes.h | 4 ++-- src/dbwrapper.h | 6 +++--- src/httpserver.h | 6 +++--- src/kernel/disconnected_transactions.h | 2 +- src/logging.h | 10 ++++----- src/net.h | 28 +++++++++++++------------- src/net_processing.h | 10 ++++----- src/netaddress.h | 6 +++--- src/netbase.h | 4 ++-- src/node/blockstorage.h | 6 +++--- src/node/mining_args.h | 2 +- src/node/protocol_version.h | 20 +++++++++--------- src/node/transaction.h | 4 ++-- src/policy/policy.h | 4 ++-- src/protocol.h | 4 ++-- src/psbt.h | 2 +- src/pubkey.h | 4 ++-- src/qt/guiconstants.h | 8 ++++---- src/qt/intro.h | 2 +- src/qt/qrimagewidget.h | 2 +- src/rpc/mining.h | 2 +- src/script/script.h | 16 +++++++-------- src/serialize.h | 2 +- src/torcontrol.h | 2 +- src/txmempool.h | 2 +- src/util/subprocess.h | 4 ++-- src/validation.h | 6 +++--- src/versionbits.h | 8 ++++---- src/wallet/coincontrol.h | 6 +++--- src/wallet/crypter.h | 6 +++--- src/wallet/scriptpubkeyman.h | 2 +- src/wallet/test/util.h | 2 +- src/wallet/wallet.h | 26 ++++++++++++------------ 36 files changed, 121 insertions(+), 121 deletions(-) diff --git a/src/chainparamsseeds.h b/src/chainparamsseeds.h index 5cf8d6ba407..729d7050826 100644 --- a/src/chainparamsseeds.h +++ b/src/chainparamsseeds.h @@ -10,7 +10,7 @@ * * Each line contains a BIP155 serialized (networkID, addr, port) tuple. */ -static const uint8_t chainparams_seed_main[] = { +inline constexpr uint8_t chainparams_seed_main[] = { 0x06,0x10,0xfc,0x11,0xf7,0x69,0x16,0xe6,0x36,0x11,0x58,0xae,0x1d,0x4a,0xfc,0xf7,0x57,0xa4,0x20,0x8d, 0x06,0x10,0xfc,0x17,0x43,0x69,0x54,0x14,0x4b,0x1f,0x56,0x89,0xd3,0xed,0x40,0x39,0x33,0x5c,0x20,0x8d, 0x06,0x10,0xfc,0x1f,0x22,0xc3,0x95,0xdc,0xa3,0xaf,0x4a,0x93,0x82,0x51,0xbe,0xb9,0x18,0x58,0x20,0x8d, @@ -2072,7 +2072,7 @@ static const uint8_t chainparams_seed_main[] = { 0x04,0x20,0xce,0x07,0x95,0xf3,0xa5,0xc1,0x90,0xc4,0x50,0xd5,0x22,0x86,0xa7,0x26,0x37,0x08,0xa2,0x31,0x1e,0x0d,0x77,0x48,0x0d,0x46,0xe0,0xfb,0x3d,0x71,0x60,0xe7,0x1d,0xce,0x20,0x8d, }; -static const uint8_t chainparams_seed_signet[] = { +inline constexpr uint8_t chainparams_seed_signet[] = { 0x06,0x10,0xfc,0x1f,0x22,0xc3,0x95,0xdc,0xa3,0xaf,0x4a,0x93,0x82,0x51,0xbe,0xb9,0x18,0x58,0x95,0xbd, 0x05,0x20,0xd7,0x4d,0xd9,0xc4,0x7c,0x80,0x24,0x1d,0x48,0x2f,0x52,0xba,0x2a,0xaf,0x5d,0xf2,0xfc,0x04,0x58,0x56,0x4a,0x61,0x0f,0xde,0x4e,0xd8,0x13,0x55,0x98,0x55,0x53,0xc1,0x00,0x00, 0x05,0x20,0xd8,0xaf,0x32,0x40,0x0d,0x25,0x72,0x91,0xf5,0x14,0x2a,0xa7,0x7b,0x9f,0x6b,0xe8,0x02,0x9f,0x16,0x5e,0xa0,0xe0,0x6d,0x85,0xcc,0x79,0xf2,0xe2,0xc1,0x2b,0xe0,0x20,0x00,0x00, @@ -2245,7 +2245,7 @@ static const uint8_t chainparams_seed_signet[] = { 0x04,0x20,0xc9,0x95,0x5a,0xf7,0x9a,0x27,0x09,0x6a,0xa2,0x24,0x65,0xb7,0x07,0xf0,0x28,0xee,0x8b,0xa9,0x5e,0x7c,0x37,0x19,0x14,0xc4,0x36,0x73,0x42,0xd2,0x87,0xae,0xa2,0x47,0x95,0xbd, }; -static const uint8_t chainparams_seed_test[] = { +inline constexpr uint8_t chainparams_seed_test[] = { 0x06,0x10,0xfc,0x1f,0x22,0xc3,0x95,0xdc,0xa3,0xaf,0x4a,0x93,0x82,0x51,0xbe,0xb9,0x18,0x58,0x47,0x9d, 0x05,0x20,0x39,0x06,0xc0,0x95,0x12,0xe1,0xf8,0x86,0xc2,0x36,0x76,0xa9,0x96,0x2a,0x9d,0xbd,0x3d,0x70,0x43,0xfc,0x99,0xbf,0x27,0x15,0xa4,0x9c,0x10,0xa1,0xd5,0xa3,0x9d,0x52,0x00,0x00, 0x05,0x20,0x40,0x81,0xae,0x55,0xb2,0x9d,0xd0,0xff,0x99,0x51,0xd8,0xbc,0x35,0xb2,0x06,0xb7,0x1c,0xf6,0x16,0x35,0xae,0xc6,0xf7,0xa4,0x72,0xf8,0x37,0x41,0x8e,0x91,0x7b,0x2e,0x00,0x00, @@ -2429,7 +2429,7 @@ static const uint8_t chainparams_seed_test[] = { 0x04,0x20,0xcc,0x99,0x76,0x52,0x43,0xcc,0x45,0x0a,0x49,0x5d,0x3f,0xa5,0x82,0xc3,0xc0,0xdb,0xcf,0xe5,0xda,0xfb,0xb3,0xd0,0xb9,0xd1,0xbc,0x1b,0x15,0x19,0xed,0xe0,0xd1,0x5f,0x47,0x9d, }; -static const uint8_t chainparams_seed_testnet4[] = { +inline constexpr uint8_t chainparams_seed_testnet4[] = { 0x06,0x10,0xfc,0x1f,0x22,0xc3,0x95,0xdc,0xa3,0xaf,0x4a,0x93,0x82,0x51,0xbe,0xb9,0x18,0x58,0xbc,0xcd, 0x05,0x20,0xd3,0xbc,0x25,0x95,0x63,0x7f,0x34,0x02,0x18,0x69,0x91,0x9a,0x79,0x57,0x10,0xc0,0xe0,0xf5,0xcd,0x84,0x56,0x95,0xec,0x43,0xa4,0x9d,0xba,0x1b,0xb3,0xea,0x34,0x60,0x00,0x00, 0x05,0x20,0xd8,0xee,0x64,0x35,0x6c,0x53,0xe7,0x40,0xb8,0xc3,0x15,0x60,0x5b,0x9c,0x66,0x3d,0xbb,0xd9,0x7c,0x99,0xcc,0x3a,0x3a,0xf6,0xcb,0xd5,0xd4,0x51,0x98,0x04,0x68,0xad,0x00,0x00, diff --git a/src/clientversion.h b/src/clientversion.h index f4822a12b69..cbdb62b24f0 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -23,7 +23,7 @@ #include #include -static const int CLIENT_VERSION = +inline constexpr int CLIENT_VERSION = 10000 * CLIENT_VERSION_MAJOR + 100 * CLIENT_VERSION_MINOR + 1 * CLIENT_VERSION_BUILD; diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index 5d22d58284d..3666525388f 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -10,18 +10,18 @@ #include /** The maximum allowed size for a serialized block, in bytes (only for buffer size limits) */ -static const unsigned int MAX_BLOCK_SERIALIZED_SIZE = 4000000; +inline constexpr unsigned int MAX_BLOCK_SERIALIZED_SIZE = 4000000; /** The maximum allowed weight for a block, see BIP 141 (network rule) */ -static const unsigned int MAX_BLOCK_WEIGHT = 4000000; +inline constexpr unsigned int MAX_BLOCK_WEIGHT = 4000000; /** The maximum allowed number of signature check operations in a block (network rule) */ -static const int64_t MAX_BLOCK_SIGOPS_COST = 80000; +inline constexpr int64_t MAX_BLOCK_SIGOPS_COST = 80000; /** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */ -static const int COINBASE_MATURITY = 100; +inline constexpr int COINBASE_MATURITY = 100; -static const int WITNESS_SCALE_FACTOR = 4; +inline constexpr int WITNESS_SCALE_FACTOR = 4; -static const size_t MIN_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 60; // 60 is the lower bound for the size of a valid serialized CTransaction -static const size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 10; // 10 is the lower bound for the size of a serialized CTransaction +inline constexpr size_t MIN_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 60; // 60 is the lower bound for the size of a valid serialized CTransaction +inline constexpr size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 10; // 10 is the lower bound for the size of a serialized CTransaction /** Flags for nSequence and nLockTime locks */ /** Interpret sequence numbers as relative lock-time constraints. */ diff --git a/src/crypto/aes.h b/src/crypto/aes.h index 617bb62de91..4892c09766c 100644 --- a/src/crypto/aes.h +++ b/src/crypto/aes.h @@ -12,8 +12,8 @@ extern "C" { #include } -static const int AES_BLOCKSIZE = 16; -static const int AES256_KEYSIZE = 32; +inline constexpr int AES_BLOCKSIZE = 16; +inline constexpr int AES256_KEYSIZE = 32; /** An encryption class for AES-256. */ class AES256Encrypt diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 1eb68a3bb1f..654919378c9 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -27,9 +27,9 @@ namespace leveldb { class Env; } // namespace leveldb -static const size_t DBWRAPPER_PREALLOC_KEY_SIZE = 64; -static const size_t DBWRAPPER_PREALLOC_VALUE_SIZE = 1024; -static const size_t DBWRAPPER_MAX_FILE_SIZE{32_MiB}; +inline constexpr size_t DBWRAPPER_PREALLOC_KEY_SIZE = 64; +inline constexpr size_t DBWRAPPER_PREALLOC_VALUE_SIZE = 1024; +inline constexpr size_t DBWRAPPER_MAX_FILE_SIZE{32_MiB}; //! User-controlled performance and debug options. struct DBOptions { diff --git a/src/httpserver.h b/src/httpserver.h index 943dc12def4..2f58d787e5c 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -32,15 +32,15 @@ class SignalInterrupt; /** * The default value for `-rpcthreads`. This number of threads will be created at startup. */ -static const int DEFAULT_HTTP_THREADS=16; +inline constexpr int DEFAULT_HTTP_THREADS=16; /** * The default value for `-rpcworkqueue`. This is the maximum depth of the work queue, * we don't allocate this number of work queue items upfront. */ -static const int DEFAULT_HTTP_WORKQUEUE=64; +inline constexpr int DEFAULT_HTTP_WORKQUEUE=64; -static const int DEFAULT_HTTP_SERVER_TIMEOUT=30; +inline constexpr int DEFAULT_HTTP_SERVER_TIMEOUT=30; enum class HTTPRequestMethod { UNKNOWN, diff --git a/src/kernel/disconnected_transactions.h b/src/kernel/disconnected_transactions.h index 50eac519332..c9f4d6f7c6c 100644 --- a/src/kernel/disconnected_transactions.h +++ b/src/kernel/disconnected_transactions.h @@ -15,7 +15,7 @@ #include /** Maximum bytes for transactions to store for processing during reorg */ -static const unsigned int MAX_DISCONNECTED_TX_POOL_BYTES{20'000'000}; +inline constexpr unsigned int MAX_DISCONNECTED_TX_POOL_BYTES{20'000'000}; /** * DisconnectedBlockTransactions diff --git a/src/logging.h b/src/logging.h index 688f2b607f0..2bb8232bcba 100644 --- a/src/logging.h +++ b/src/logging.h @@ -27,11 +27,11 @@ #include #include -static const bool DEFAULT_LOGTIMEMICROS = false; -static const bool DEFAULT_LOGIPS = false; -static const bool DEFAULT_LOGTIMESTAMPS = true; -static const bool DEFAULT_LOGTHREADNAMES = false; -static const bool DEFAULT_LOGSOURCELOCATIONS = false; +inline constexpr bool DEFAULT_LOGTIMEMICROS = false; +inline constexpr bool DEFAULT_LOGIPS = false; +inline constexpr bool DEFAULT_LOGTIMESTAMPS = true; +inline constexpr bool DEFAULT_LOGTHREADNAMES = false; +inline constexpr bool DEFAULT_LOGSOURCELOCATIONS = false; inline constexpr bool DEFAULT_LOGLEVELALWAYS = false; extern const char * const DEFAULT_DEBUGLOGFILE; diff --git a/src/net.h b/src/net.h index 9911d91fb92..16ae5a6522a 100644 --- a/src/net.h +++ b/src/net.h @@ -62,43 +62,43 @@ inline constexpr auto FEELER_INTERVAL = 2min; /** Run the extra block-relay-only connection loop once every 5 minutes. **/ inline constexpr auto EXTRA_BLOCK_RELAY_ONLY_PEER_INTERVAL = 5min; /** Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable). */ -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000; +inline constexpr unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000; /** Maximum length of the user agent string in `version` message */ -static const unsigned int MAX_SUBVERSION_LENGTH = 256; +inline constexpr unsigned int MAX_SUBVERSION_LENGTH = 256; /** Maximum number of automatic outgoing nodes over which we'll relay everything (blocks, tx, addrs, etc) */ -static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 8; +inline constexpr int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 8; /** Maximum number of addnode outgoing nodes */ -static const int MAX_ADDNODE_CONNECTIONS = 8; +inline constexpr int MAX_ADDNODE_CONNECTIONS = 8; /** Maximum number of block-relay-only outgoing connections */ -static const int MAX_BLOCK_RELAY_ONLY_CONNECTIONS = 2; +inline constexpr int MAX_BLOCK_RELAY_ONLY_CONNECTIONS = 2; /** Maximum number of feeler connections */ -static const int MAX_FEELER_CONNECTIONS = 1; +inline constexpr int MAX_FEELER_CONNECTIONS = 1; /** Maximum number of private broadcast connections */ inline constexpr size_t MAX_PRIVATE_BROADCAST_CONNECTIONS{64}; /** -listen default */ -static const bool DEFAULT_LISTEN = true; +inline constexpr bool DEFAULT_LISTEN = true; /** The maximum number of peer connections to maintain. */ -static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS{200}; +inline constexpr unsigned int DEFAULT_MAX_PEER_CONNECTIONS{200}; /** Default percentage of inbound connection slots that tx-relaying peers can use */ -static const int DEFAULT_FULL_RELAY_INBOUND_PCT{50}; +inline constexpr int DEFAULT_FULL_RELAY_INBOUND_PCT{50}; /** The default for -maxuploadtarget. 0 = Unlimited */ static const std::string DEFAULT_MAX_UPLOAD_TARGET{"0M"}; /** Default for blocks only*/ -static const bool DEFAULT_BLOCKSONLY = false; +inline constexpr bool DEFAULT_BLOCKSONLY = false; /** -peertimeout default */ -static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60; +inline constexpr int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60; /** Default for -privatebroadcast. */ inline constexpr bool DEFAULT_PRIVATE_BROADCAST{false}; /** Number of file descriptors required for message capture **/ -static const int NUM_FDS_MESSAGE_CAPTURE = 1; +inline constexpr int NUM_FDS_MESSAGE_CAPTURE = 1; /** Interval for ASMap Health Check **/ inline constexpr std::chrono::hours ASMAP_HEALTH_CHECK_INTERVAL{24}; inline constexpr bool DEFAULT_FORCEDNSSEED{false}; inline constexpr bool DEFAULT_DNSSEED{true}; inline constexpr bool DEFAULT_FIXEDSEEDS{true}; -static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000; -static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000; +inline constexpr size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000; +inline constexpr size_t DEFAULT_MAXSENDBUFFER = 1 * 1000; inline constexpr bool DEFAULT_V2_TRANSPORT{true}; diff --git a/src/net_processing.h b/src/net_processing.h index 50c329e2891..f26b95c5787 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -41,16 +41,16 @@ class Warnings; inline constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false}; /** Default number of non-mempool transactions to keep around for block reconstruction. Includes orphan, replaced, and rejected transactions. */ -static const uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN{100}; +inline constexpr uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN{100}; /** Default maximum per-second rate for sending transaction inventory to peers. */ inline constexpr unsigned int DEFAULT_TX_SEND_RATE{14}; -static const bool DEFAULT_PEERBLOOMFILTERS = false; -static const bool DEFAULT_PEERBLOCKFILTERS = false; +inline constexpr bool DEFAULT_PEERBLOOMFILTERS = false; +inline constexpr bool DEFAULT_PEERBLOCKFILTERS = false; /** Maximum number of outstanding CMPCTBLOCK requests for the same block. */ -static const unsigned int MAX_CMPCTBLOCKS_INFLIGHT_PER_BLOCK = 3; +inline constexpr unsigned int MAX_CMPCTBLOCKS_INFLIGHT_PER_BLOCK = 3; /** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends * less than this number, we reached its tip. Changing this value is a protocol upgrade. */ -static const unsigned int MAX_HEADERS_RESULTS = 2000; +inline constexpr unsigned int MAX_HEADERS_RESULTS = 2000; /** The compactblocks version we support. See BIP 152. */ inline constexpr uint64_t CMPCTBLOCKS_VERSION{2}; diff --git a/src/netaddress.h b/src/netaddress.h index 60028fd7aca..bb452a11275 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -59,14 +59,14 @@ enum Network { /// Prefix of an IPv6 address when it contains an embedded IPv4 address. /// Used when (un)serializing addresses in ADDRv1 format (pre-BIP155). -static const std::array IPV4_IN_IPV6_PREFIX{ +inline constexpr std::array IPV4_IN_IPV6_PREFIX{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF}; /// Prefix of an IPv6 address when it contains an embedded TORv2 address. /// Used when (un)serializing addresses in ADDRv1 format (pre-BIP155). /// Such dummy IPv6 addresses are guaranteed to not be publicly routable as they /// fall under RFC4193's fc00::/7 subnet allocated to unique-local addresses. -static const std::array TORV2_IN_IPV6_PREFIX{ +inline constexpr std::array TORV2_IN_IPV6_PREFIX{ 0xFD, 0x87, 0xD8, 0x7E, 0xEB, 0x43}; /// Prefix of an IPv6 address when it contains an embedded "internal" address. @@ -74,7 +74,7 @@ static const std::array TORV2_IN_IPV6_PREFIX{ /// The prefix comes from 0xFD + SHA256("bitcoin")[0:5]. /// Such dummy IPv6 addresses are guaranteed to not be publicly routable as they /// fall under RFC4193's fc00::/7 subnet allocated to unique-local addresses. -static const std::array INTERNAL_IN_IPV6_PREFIX{ +inline constexpr std::array INTERNAL_IN_IPV6_PREFIX{ 0xFD, 0x6B, 0x88, 0xC0, 0x87, 0x24 // 0xFD + sha256("bitcoin")[0:5]. }; diff --git a/src/netbase.h b/src/netbase.h index af51853a51a..ae85eebda41 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -25,9 +25,9 @@ extern int nConnectTimeout; extern bool fNameLookup; //! -timeout default -static const int DEFAULT_CONNECT_TIMEOUT = 5000; +inline constexpr int DEFAULT_CONNECT_TIMEOUT = 5000; //! -dns default -static const int DEFAULT_NAME_LOOKUP = true; +inline constexpr int DEFAULT_NAME_LOOKUP = true; /** Prefix for unix domain socket addresses (which are local filesystem paths) */ const std::string ADDR_PREFIX_UNIX = "unix:"; diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h index 9178fb21824..c871bf3f924 100644 --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -119,11 +119,11 @@ using kernel::CBlockFileInfo; using kernel::BlockTreeDB; /** The pre-allocation chunk size for blk?????.dat files (since 0.8) */ -static const unsigned int BLOCKFILE_CHUNK_SIZE{16_MiB}; +inline constexpr unsigned int BLOCKFILE_CHUNK_SIZE{16_MiB}; /** The pre-allocation chunk size for rev?????.dat files (since 0.8) */ -static const unsigned int UNDOFILE_CHUNK_SIZE{1_MiB}; +inline constexpr unsigned int UNDOFILE_CHUNK_SIZE{1_MiB}; /** The maximum size of a blk?????.dat file (since 0.8) */ -static const unsigned int MAX_BLOCKFILE_SIZE{128_MiB}; +inline constexpr unsigned int MAX_BLOCKFILE_SIZE{128_MiB}; /** Size of header written by WriteBlock before a serialized CBlock (8 bytes) */ inline constexpr uint32_t STORAGE_HEADER_BYTES{std::tuple_size_v + sizeof(unsigned int)}; diff --git a/src/node/mining_args.h b/src/node/mining_args.h index 8baa7395285..053913168d7 100644 --- a/src/node/mining_args.h +++ b/src/node/mining_args.h @@ -12,7 +12,7 @@ class ArgsManager; namespace node { -static const bool DEFAULT_PRINT_MODIFIED_FEE = false; +inline constexpr bool DEFAULT_PRINT_MODIFIED_FEE = false; /** * Read the mining options set in \p args. Returns an error if one was diff --git a/src/node/protocol_version.h b/src/node/protocol_version.h index a72ac777465..db58f3a74a3 100644 --- a/src/node/protocol_version.h +++ b/src/node/protocol_version.h @@ -9,33 +9,33 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 70017; +inline constexpr int PROTOCOL_VERSION = 70017; //! initial proto version, to be increased after version/verack negotiation -static const int INIT_PROTO_VERSION = 209; +inline constexpr int INIT_PROTO_VERSION = 209; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 31800; +inline constexpr int MIN_PEER_PROTO_VERSION = 31800; //! BIP 0031, pong message, is enabled for all versions AFTER this one -static const int BIP0031_VERSION = 60000; +inline constexpr int BIP0031_VERSION = 60000; //! "sendheaders" message type and announcing blocks with headers starts with this version -static const int SENDHEADERS_VERSION = 70012; +inline constexpr int SENDHEADERS_VERSION = 70012; //! "feefilter" tells peers to filter invs to you by fee starts with this version -static const int FEEFILTER_VERSION = 70013; +inline constexpr int FEEFILTER_VERSION = 70013; //! short-id-based block download starts with this version -static const int SHORT_IDS_BLOCKS_VERSION = 70014; +inline constexpr int SHORT_IDS_BLOCKS_VERSION = 70014; //! not banning for invalid compact blocks starts with this version -static const int INVALID_CB_NO_BAN_VERSION = 70015; +inline constexpr int INVALID_CB_NO_BAN_VERSION = 70015; //! "wtxidrelay" message type for wtxid-based relay starts with this version -static const int WTXID_RELAY_VERSION = 70016; +inline constexpr int WTXID_RELAY_VERSION = 70016; //! "feature" message type for feature negotiation starts with this version -static const int FEATURE_VERSION = 70017; +inline constexpr int FEATURE_VERSION = 70017; #endif // BITCOIN_NODE_PROTOCOL_VERSION_H diff --git a/src/node/transaction.h b/src/node/transaction.h index d27057a4a93..c83a28ed1bd 100644 --- a/src/node/transaction.h +++ b/src/node/transaction.h @@ -25,13 +25,13 @@ struct NodeContext; * By default, a transaction with a fee rate higher than this will be rejected * by these RPCs and the GUI. This can be overridden with the maxfeerate argument. */ -static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10}; +inline constexpr CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10}; /** Maximum burn value for sendrawtransaction, submitpackage, and testmempoolaccept RPC calls. * By default, a transaction with a burn value higher than this will be rejected * by these RPCs and the GUI. This can be overridden with the maxburnamount argument. */ -static const CAmount DEFAULT_MAX_BURN_AMOUNT{0}; +inline constexpr CAmount DEFAULT_MAX_BURN_AMOUNT{0}; /** * Submit a transaction to the mempool and (optionally) relay it to all P2P peers. diff --git a/src/policy/policy.h b/src/policy/policy.h index 87d20486bbf..54434b9b60e 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -77,11 +77,11 @@ inline constexpr unsigned int DEFAULT_ANCESTOR_LIMIT{25}; /** Default for -limitdescendantcount, max number of in-mempool descendants */ inline constexpr unsigned int DEFAULT_DESCENDANT_LIMIT{25}; /** Default for -datacarrier */ -static const bool DEFAULT_ACCEPT_DATACARRIER = true; +inline constexpr bool DEFAULT_ACCEPT_DATACARRIER = true; /** * Default setting for -datacarriersize in vbytes. */ -static const unsigned int MAX_OP_RETURN_RELAY = MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR; +inline constexpr unsigned int MAX_OP_RETURN_RELAY = MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR; /** * An extra transaction can be added to a package, as long as it only has one * ancestor and is no larger than this. Not really any reason to make this diff --git a/src/protocol.h b/src/protocol.h index a53f15e455a..0fd3c59261e 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -487,8 +487,8 @@ public: }; /** getdata message type flags */ -const uint32_t MSG_WITNESS_FLAG = 1 << 30; -const uint32_t MSG_TYPE_MASK = 0xffffffff >> 2; +inline constexpr uint32_t MSG_WITNESS_FLAG = 1 << 30; +inline constexpr uint32_t MSG_TYPE_MASK = 0xffffffff >> 2; /** getdata / inv message types. * These numbers are defined by the protocol. When adding a new value, be sure diff --git a/src/psbt.h b/src/psbt.h index 233a4fb673d..30e0036f85c 100644 --- a/src/psbt.h +++ b/src/psbt.h @@ -90,7 +90,7 @@ inline constexpr uint8_t PSBT_SEPARATOR = 0x00; // BIP 174 does not specify a maximum file size, but we set a limit anyway // to prevent reading a stream indefinitely and running out of memory. -const std::streamsize MAX_FILE_SIZE_PSBT = 100000000; // 100 MB +inline constexpr std::streamsize MAX_FILE_SIZE_PSBT = 100000000; // 100 MB // PSBT version number inline constexpr uint32_t PSBT_HIGHEST_VERSION = 2; diff --git a/src/pubkey.h b/src/pubkey.h index 28dc4a80b56..8acfd7241c7 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -16,8 +16,8 @@ #include #include -const unsigned int BIP32_EXTKEY_SIZE = 74; -const unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE = 78; +inline constexpr unsigned int BIP32_EXTKEY_SIZE = 74; +inline constexpr unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE = 78; using KeyFingerprint = std::array; diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index 79d5b577e3b..462b7413ea1 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -17,12 +17,12 @@ inline constexpr auto MODEL_UPDATE_DELAY{250ms}; inline constexpr auto SHUTDOWN_POLLING_DELAY{200ms}; /* AskPassphraseDialog -- Maximum passphrase length */ -static const int MAX_PASSPHRASE_SIZE = 1024; +inline constexpr int MAX_PASSPHRASE_SIZE = 1024; /* BitcoinGUI -- Size of icons in status bar */ -static const int STATUSBAR_ICONSIZE = 16; +inline constexpr int STATUSBAR_ICONSIZE = 16; -static const bool DEFAULT_SPLASHSCREEN = true; +inline constexpr bool DEFAULT_SPLASHSCREEN = true; /* Invalid field background style */ #define STYLE_INVALID "border: 3px solid #FF8080" @@ -41,7 +41,7 @@ static const bool DEFAULT_SPLASHSCREEN = true; /* Tooltips longer than this (in characters) are converted into rich text, so that they can be word-wrapped. */ -static const int TOOLTIP_WRAP_THRESHOLD = 80; +inline constexpr int TOOLTIP_WRAP_THRESHOLD = 80; /* Number of frames in spinner animation */ #define SPINNER_FRAMES 36 diff --git a/src/qt/intro.h b/src/qt/intro.h index db6c1d50b23..c8e015baeff 100644 --- a/src/qt/intro.h +++ b/src/qt/intro.h @@ -11,7 +11,7 @@ #include #include -static const bool DEFAULT_CHOOSE_DATADIR = false; +inline constexpr bool DEFAULT_CHOOSE_DATADIR = false; namespace interfaces { class Node; diff --git a/src/qt/qrimagewidget.h b/src/qt/qrimagewidget.h index b65b2b7a0dc..6eb9bed2a75 100644 --- a/src/qt/qrimagewidget.h +++ b/src/qt/qrimagewidget.h @@ -9,7 +9,7 @@ #include /* Maximum allowed URI length */ -static const int MAX_URI_LENGTH = 255; +inline constexpr int MAX_URI_LENGTH = 255; /* Size of exported QR Code image */ inline constexpr int QR_IMAGE_SIZE = 300; diff --git a/src/rpc/mining.h b/src/rpc/mining.h index a6c243c22c5..e99a9e74d38 100644 --- a/src/rpc/mining.h +++ b/src/rpc/mining.h @@ -8,6 +8,6 @@ #include /** Default max iterations to try in RPC generatetodescriptor, generatetoaddress, and generateblock. */ -static const uint64_t DEFAULT_MAX_TRIES{1000000}; +inline constexpr uint64_t DEFAULT_MAX_TRIES{1000000}; #endif // BITCOIN_RPC_MINING_H diff --git a/src/script/script.h b/src/script/script.h index 5590ecce215..6997df99eea 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -26,32 +26,32 @@ #include // Maximum number of bytes pushable to the stack -static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; +inline constexpr unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // Maximum number of non-push operations per script -static const int MAX_OPS_PER_SCRIPT = 201; +inline constexpr int MAX_OPS_PER_SCRIPT = 201; // Maximum number of public keys per multisig -static const int MAX_PUBKEYS_PER_MULTISIG = 20; +inline constexpr int MAX_PUBKEYS_PER_MULTISIG = 20; /** The limit of keys in OP_CHECKSIGADD-based scripts. It is due to the stack limit in BIP342. */ inline constexpr unsigned int MAX_PUBKEYS_PER_MULTI_A = 999; // Maximum script length in bytes -static const int MAX_SCRIPT_SIZE = 10000; +inline constexpr int MAX_SCRIPT_SIZE = 10000; // Maximum number of values on script interpreter stack -static const int MAX_STACK_SIZE = 1000; +inline constexpr int MAX_STACK_SIZE = 1000; // Threshold for nLockTime: below this value it is interpreted as block number, // otherwise as UNIX timestamp. -static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC +inline constexpr unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC // Maximum nLockTime. Since a lock time indicates the last invalid timestamp, a // transaction with this lock time will never be valid unless lock time // checking is disabled (by setting all input sequence numbers to // SEQUENCE_FINAL). -static const uint32_t LOCKTIME_MAX = 0xFFFFFFFFU; +inline constexpr uint32_t LOCKTIME_MAX = 0xFFFFFFFFU; // Tag for input annex. If there are at least two witness elements for a transaction input, // and the first byte of the last element is 0x50, this last element is called annex, and @@ -214,7 +214,7 @@ enum opcodetype }; // Maximum value that an opcode can be -static const unsigned int MAX_OPCODE = OP_NOP10; +inline constexpr unsigned int MAX_OPCODE = OP_NOP10; std::string GetOpName(opcodetype opcode); diff --git a/src/serialize.h b/src/serialize.h index 5d8b4109b11..4dbfe819b32 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -35,7 +35,7 @@ inline constexpr uint64_t MAX_SIZE = 0x02000000; /** Maximum amount of memory (in bytes) to allocate at once when deserializing vectors. */ -static const unsigned int MAX_VECTOR_ALLOCATE = 5000000; +inline constexpr unsigned int MAX_VECTOR_ALLOCATE = 5000000; /** * Dummy data type to identify deserializing constructors. diff --git a/src/torcontrol.h b/src/torcontrol.h index 06a9d3e8bd3..8079c356447 100644 --- a/src/torcontrol.h +++ b/src/torcontrol.h @@ -24,7 +24,7 @@ constexpr uint16_t DEFAULT_TOR_SOCKS_PORT{9050}; constexpr int DEFAULT_TOR_CONTROL_PORT = 9051; extern const std::string DEFAULT_TOR_CONTROL; -static const bool DEFAULT_LISTEN_ONION = true; +inline constexpr bool DEFAULT_LISTEN_ONION = true; /** Tor control reply code. Ref: https://spec.torproject.org/control-spec/replies.html */ constexpr int TOR_REPLY_OK{250}; diff --git a/src/txmempool.h b/src/txmempool.h index bf033474b02..35339d3f252 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -47,7 +47,7 @@ class ValidationSignals; struct bilingual_str; /** 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; +inline constexpr uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF; /** How much linearization cost required for TxGraph clusters to have * "acceptable" quality, if they cannot be optimally linearized with less cost. */ diff --git a/src/util/subprocess.h b/src/util/subprocess.h index 3d01f4b7f9c..022fe43a00a 100644 --- a/src/util/subprocess.h +++ b/src/util/subprocess.h @@ -116,12 +116,12 @@ namespace subprocess { // Max buffer size allocated on stack for read error // from pipe -static const size_t SP_MAX_ERR_BUF_SIZ = 1024; +inline constexpr size_t SP_MAX_ERR_BUF_SIZ = 1024; // Default buffer capacity for OutBuffer and ErrBuffer. // If the data exceeds this capacity, the buffer size is grown // by 1.5 times its previous capacity -static const size_t DEFAULT_BUF_CAP_BYTES = 8192; +inline constexpr size_t DEFAULT_BUF_CAP_BYTES = 8192; /*----------------------------------------------- diff --git a/src/validation.h b/src/validation.h index 52480e14018..d1141afe5a3 100644 --- a/src/validation.h +++ b/src/validation.h @@ -73,8 +73,8 @@ class SignalInterrupt; } // namespace util /** Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ActiveChain().Tip() will not be pruned. */ -static const unsigned int MIN_BLOCKS_TO_KEEP = 288; -static const signed int DEFAULT_CHECKBLOCKS = 6; +inline constexpr unsigned int MIN_BLOCKS_TO_KEEP = 288; +inline constexpr signed int DEFAULT_CHECKBLOCKS = 6; inline constexpr int DEFAULT_CHECKLEVEL{3}; // Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev???.dat) // At 1MB per block, 288 blocks = 288MB. @@ -84,7 +84,7 @@ inline constexpr int DEFAULT_CHECKLEVEL{3}; // full block file chunks, we need the high water mark which triggers the prune to be // one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB // Setting the target to >= 550 MiB will make it likely we can respect the target. -static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES{550_MiB}; +inline constexpr uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES{550_MiB}; /** Maximum number of dedicated script-checking threads allowed */ inline constexpr int MAX_SCRIPTCHECK_THREADS{15}; diff --git a/src/versionbits.h b/src/versionbits.h index f88ead0dce6..6e3743c29e7 100644 --- a/src/versionbits.h +++ b/src/versionbits.h @@ -16,13 +16,13 @@ class CChainParams; /** What block version to use for new blocks (pre versionbits) */ -static const int32_t VERSIONBITS_LAST_OLD_BLOCK_VERSION = 4; +inline constexpr int32_t VERSIONBITS_LAST_OLD_BLOCK_VERSION = 4; /** What bits to set in version for versionbits blocks */ -static const int32_t VERSIONBITS_TOP_BITS = 0x20000000UL; +inline constexpr int32_t VERSIONBITS_TOP_BITS = 0x20000000UL; /** What bitmask determines whether versionbits is in use */ -static const int32_t VERSIONBITS_TOP_MASK = 0xE0000000UL; +inline constexpr int32_t VERSIONBITS_TOP_MASK = 0xE0000000UL; /** Total bits available for versionbits (BIP 323) */ -static const int32_t VERSIONBITS_NUM_BITS = 5; +inline constexpr int32_t VERSIONBITS_NUM_BITS = 5; /** Opaque type for BIP9 state. See versionbits_impl.h for details. */ enum class ThresholdState : uint8_t; diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h index f67649f7e44..9bc04fc0d87 100644 --- a/src/wallet/coincontrol.h +++ b/src/wallet/coincontrol.h @@ -19,10 +19,10 @@ #include namespace wallet { -const int DEFAULT_MIN_DEPTH = 0; -const int DEFAULT_MAX_DEPTH = 9999999; +inline constexpr int DEFAULT_MIN_DEPTH = 0; +inline constexpr int DEFAULT_MAX_DEPTH = 9999999; -const int DEFAULT_WALLET_TX_VERSION = CTransaction::CURRENT_VERSION; +inline constexpr int DEFAULT_WALLET_TX_VERSION = CTransaction::CURRENT_VERSION; //! Default for -avoidpartialspends inline constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false; diff --git a/src/wallet/crypter.h b/src/wallet/crypter.h index 90871245e57..03fd83258e8 100644 --- a/src/wallet/crypter.h +++ b/src/wallet/crypter.h @@ -11,9 +11,9 @@ namespace wallet { -const unsigned int WALLET_CRYPTO_KEY_SIZE = 32; -const unsigned int WALLET_CRYPTO_SALT_SIZE = 8; -const unsigned int WALLET_CRYPTO_IV_SIZE = 16; +inline constexpr unsigned int WALLET_CRYPTO_KEY_SIZE = 32; +inline constexpr unsigned int WALLET_CRYPTO_SALT_SIZE = 8; +inline constexpr unsigned int WALLET_CRYPTO_IV_SIZE = 16; /** * Private key encryption is done based on a CMasterKey, diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index ccf8ae10d34..94a4f3318f4 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -61,7 +61,7 @@ public: inline constexpr int64_t UNKNOWN_TIME = std::numeric_limits::max(); //! Default for -keypool -static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000; +inline constexpr unsigned int DEFAULT_KEYPOOL_SIZE = 1000; std::vector GetAffectedKeys(const CScript& spk, const SigningProvider& provider); diff --git a/src/wallet/test/util.h b/src/wallet/test/util.h index 0af46e5577a..050a80b064a 100644 --- a/src/wallet/test/util.h +++ b/src/wallet/test/util.h @@ -25,7 +25,7 @@ class CWallet; class WalletDatabase; struct WalletContext; -static const DatabaseFormat DATABASE_FORMATS[] = { +inline constexpr DatabaseFormat DATABASE_FORMATS[] = { DatabaseFormat::SQLITE, }; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 6d26b386bea..ce9d3d2e188 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -103,13 +103,13 @@ void NotifyWalletLoaded(WalletContext& context, const std::shared_ptr& std::unique_ptr MakeWalletDatabase(const std::string& name, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error); //! -fallbackfee default -static const CAmount DEFAULT_FALLBACK_FEE = 0; +inline constexpr CAmount DEFAULT_FALLBACK_FEE = 0; //! -discardfee default -static const CAmount DEFAULT_DISCARD_FEE = 10000; +inline constexpr CAmount DEFAULT_DISCARD_FEE = 10000; //! -mintxfee default -static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000; +inline constexpr CAmount DEFAULT_TRANSACTION_MINFEE = 1000; //! -consolidatefeerate default -static const CAmount DEFAULT_CONSOLIDATE_FEERATE{10000}; // 10 sat/vbyte +inline constexpr CAmount DEFAULT_CONSOLIDATE_FEERATE{10000}; // 10 sat/vbyte /** * maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled by default * @@ -117,22 +117,22 @@ static const CAmount DEFAULT_CONSOLIDATE_FEERATE{10000}; // 10 sat/vbyte * A value of 0 (current default) means to attempt to do partial spend avoidance, and use its results if the fees remain *unchanged* * A value > 0 means to do partial spend avoidance if the fee difference against a regular coin selection instance is in the range [0..value]. */ -static const CAmount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE = 0; +inline constexpr CAmount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE = 0; //! discourage APS fee higher than this amount constexpr CAmount HIGH_APS_FEE{COIN / 10000}; //! minimum recommended increment for replacement txs -static const CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000; +inline constexpr CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000; //! Default for -spendzeroconfchange -static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true; +inline constexpr bool DEFAULT_SPEND_ZEROCONF_CHANGE = true; //! Default for -walletrejectlongchains -static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS{true}; +inline constexpr bool DEFAULT_WALLET_REJECT_LONG_CHAINS{true}; //! -txconfirmtarget default -static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6; +inline constexpr unsigned int DEFAULT_TX_CONFIRM_TARGET = 6; //! -walletrbf default -static const bool DEFAULT_WALLET_RBF = true; -static const bool DEFAULT_WALLETBROADCAST = true; -static const bool DEFAULT_DISABLE_WALLET = false; -static const bool DEFAULT_WALLETCROSSCHAIN = false; +inline constexpr bool DEFAULT_WALLET_RBF = true; +inline constexpr bool DEFAULT_WALLETBROADCAST = true; +inline constexpr bool DEFAULT_DISABLE_WALLET = false; +inline constexpr bool DEFAULT_WALLETCROSSCHAIN = false; //! -maxtxfee default constexpr CAmount DEFAULT_TRANSACTION_MAXFEE{COIN / 10}; //! Discourage users to set fees higher than this amount (in satoshis) per kB From fa08bbed8dd2e31ff1d6c6f015063b07008701fc Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Tue, 4 Aug 2026 09:18:47 +0200 Subject: [PATCH 5/9] contrib: Adjust generate-seeds.py to write inline constexpr Otherwise, the changes in the previous commit will be reverted when this script regenerates the header. Co-Authored-By: l0rinc --- contrib/seeds/generate-seeds.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py index 2dfad0c70e5..ff2b4028f00 100755 --- a/contrib/seeds/generate-seeds.py +++ b/contrib/seeds/generate-seeds.py @@ -22,9 +22,9 @@ These files must consist of lines in the format The output will be several data structures with the peers in binary format: - static const uint8_t chainparams_seed_{main,signet,test,testnet4}[]={ - ... - } + inline constexpr uint8_t chainparams_seed_{main,signet,test,testnet4}[]{ + ... + }; These should be pasted into `src/chainparamsseeds.h`. ''' @@ -137,7 +137,7 @@ def bip155_serialize(spec): return r def process_nodes(g, f, structname): - g.write('static const uint8_t %s[] = {\n' % structname) + g.write("inline constexpr uint8_t %s[]{\n" % structname) for line in f: comment = line.find('#') if comment != -1: From fab1a62c870e5bac92ee89b8444fd5910dfd5034 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 31 Jul 2026 08:35:45 +0200 Subject: [PATCH 6/9] refactor: Use inline constexpr for string literals in headers This is needed for the next scripted-diff commit, which would otherwise turn the const from `static const char*` into `inline const char*`. --- src/index/blockfilterindex.h | 2 +- src/univalue/include/univalue_escapes.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index/blockfilterindex.h b/src/index/blockfilterindex.h index 77b87ff4765..12b5741138d 100644 --- a/src/index/blockfilterindex.h +++ b/src/index/blockfilterindex.h @@ -25,7 +25,7 @@ class BlockFilter; class CBlockIndex; enum class BlockFilterType : uint8_t; -static const char* const DEFAULT_BLOCKFILTERINDEX = "0"; +inline constexpr const char* DEFAULT_BLOCKFILTERINDEX{"0"}; /** Interval between compact filter checkpoints. See BIP 157. */ inline constexpr int CFCHECKPT_INTERVAL = 1000; diff --git a/src/univalue/include/univalue_escapes.h b/src/univalue/include/univalue_escapes.h index 7f4d89b09dc..edce915c7d0 100644 --- a/src/univalue/include/univalue_escapes.h +++ b/src/univalue/include/univalue_escapes.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H #define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H -static const char *escapes[256] = { +inline constexpr const char* escapes[256]{ "\\u0000", "\\u0001", "\\u0002", From fa74f58a262096f25d5a3a4ec4951f4ce2a31792 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 31 Jul 2026 10:34:02 +0200 Subject: [PATCH 7/9] scripted-diff: Use inline const over (static) const Both are fine and this refactor shouldn't change any behavior. However, inline const will ensure each symbol has a single address across all TU, making the release binary smaller. -BEGIN VERIFY SCRIPT- # Replace `static const` sed -i "s/^static const /inline const /" $( \ git grep -l "^static const " -- \ '*.h' \ ':(exclude)src/leveldb' \ ':(exclude)src/secp256k1' \ ) # Replace plain `const` sed -i --regexp-extended 's/^const (\S+ \w+(\[\])? ?[={])/inline &/' $( \ git grep -l '^const ' -- \ '*.h' \ ':(exclude)src/leveldb' \ ':(exclude)src/secp256k1' \ ) -END VERIFY SCRIPT- --- src/addresstype.h | 2 +- src/net.h | 2 +- src/netbase.h | 2 +- src/node/utxo_snapshot.h | 2 +- src/policy/feerate.h | 4 ++-- src/script/miniscript.h | 10 +++++----- src/test/util/script.h | 12 ++++++------ src/wallet/rpc/util.h | 2 +- src/wallet/scriptpubkeyman.h | 2 +- src/wallet/test/util.h | 2 +- src/wallet/wallet.h | 4 ++-- src/zmq/zmqutil.h | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/addresstype.h b/src/addresstype.h index 862049dec73..79fcf3d1db5 100644 --- a/src/addresstype.h +++ b/src/addresstype.h @@ -118,7 +118,7 @@ public: }; /** Witness program for Pay-to-Anchor output script type */ -static const std::vector ANCHOR_BYTES{0x4e, 0x73}; +inline const std::vector ANCHOR_BYTES{0x4e, 0x73}; struct PayToAnchor : public WitnessUnknown { diff --git a/src/net.h b/src/net.h index 16ae5a6522a..ea0c651d11e 100644 --- a/src/net.h +++ b/src/net.h @@ -82,7 +82,7 @@ inline constexpr unsigned int DEFAULT_MAX_PEER_CONNECTIONS{200}; /** Default percentage of inbound connection slots that tx-relaying peers can use */ inline constexpr int DEFAULT_FULL_RELAY_INBOUND_PCT{50}; /** The default for -maxuploadtarget. 0 = Unlimited */ -static const std::string DEFAULT_MAX_UPLOAD_TARGET{"0M"}; +inline const std::string DEFAULT_MAX_UPLOAD_TARGET{"0M"}; /** Default for blocks only*/ inline constexpr bool DEFAULT_BLOCKSONLY = false; /** -peertimeout default */ diff --git a/src/netbase.h b/src/netbase.h index ae85eebda41..3bde9ad4471 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -30,7 +30,7 @@ inline constexpr int DEFAULT_CONNECT_TIMEOUT = 5000; inline constexpr int DEFAULT_NAME_LOOKUP = true; /** Prefix for unix domain socket addresses (which are local filesystem paths) */ -const std::string ADDR_PREFIX_UNIX = "unix:"; +inline const std::string ADDR_PREFIX_UNIX = "unix:"; enum class ConnectionDirection { None = 0, diff --git a/src/node/utxo_snapshot.h b/src/node/utxo_snapshot.h index 8807c27edf5..12a451808b3 100644 --- a/src/node/utxo_snapshot.h +++ b/src/node/utxo_snapshot.h @@ -110,7 +110,7 @@ public: //! //! Because we only allow loading a single snapshot at a time, there will only be one //! chainstate directory with this filename present within it. -const fs::path SNAPSHOT_BLOCKHASH_FILENAME{"base_blockhash"}; +inline const fs::path SNAPSHOT_BLOCKHASH_FILENAME{"base_blockhash"}; //! Write out the blockhash of the snapshot base block that was used to construct //! this chainstate. This value is read in during subsequent initializations and diff --git a/src/policy/feerate.h b/src/policy/feerate.h index c397a5c23ac..965edf25f22 100644 --- a/src/policy/feerate.h +++ b/src/policy/feerate.h @@ -16,8 +16,8 @@ #include #include -const std::string CURRENCY_UNIT = "BTC"; // One formatted unit -const std::string CURRENCY_ATOM = "sat"; // One indivisible minimum value unit +inline const std::string CURRENCY_UNIT = "BTC"; // One formatted unit +inline const std::string CURRENCY_ATOM = "sat"; // One indivisible minimum value unit enum class FeeRateFormat { BTC_KVB, //!< Use BTC/kvB fee rate unit diff --git a/src/script/miniscript.h b/src/script/miniscript.h index f0867acf3ee..b088619fb47 100644 --- a/src/script/miniscript.h +++ b/src/script/miniscript.h @@ -342,15 +342,15 @@ struct InputStack { }; /** A stack consisting of a single zero-length element (interpreted as 0 by the script interpreter in numeric context). */ -static const auto ZERO = InputStack(std::vector()); +inline const auto ZERO = InputStack(std::vector()); /** A stack consisting of a single malleable 32-byte 0x0000...0000 element (for dissatisfying hash challenges). */ -static const auto ZERO32 = InputStack(std::vector(32, 0)).SetMalleable(); +inline const auto ZERO32 = InputStack(std::vector(32, 0)).SetMalleable(); /** A stack consisting of a single 0x01 element (interpreted as 1 by the script interpreted in numeric context). */ -static const auto ONE = InputStack(Vector((unsigned char)1)); +inline const auto ONE = InputStack(Vector((unsigned char)1)); /** The empty stack. */ -static const auto EMPTY = InputStack(); +inline const auto EMPTY = InputStack(); /** A stack representing the lack of any (dis)satisfactions. */ -static const auto INVALID = InputStack().SetAvailable(Availability::NO); +inline const auto INVALID = InputStack().SetAvailable(Availability::NO); //! A pair of a satisfaction and a dissatisfaction InputStack. struct InputResult { diff --git a/src/test/util/script.h b/src/test/util/script.h index 44d9acd9197..e3b58118384 100644 --- a/src/test/util/script.h +++ b/src/test/util/script.h @@ -9,8 +9,8 @@ #include