From fa74f58a262096f25d5a3a4ec4951f4ce2a31792 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 31 Jul 2026 10:34:02 +0200 Subject: [PATCH] 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