mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
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-
This commit is contained in:
@@ -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<MessageStartChars> + sizeof(unsigned int)};
|
||||
inline constexpr uint32_t STORAGE_HEADER_BYTES{std::tuple_size_v<MessageStartChars> + 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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <tuple>
|
||||
|
||||
/** Supported transaction reconciliation protocol version */
|
||||
static constexpr uint32_t TXRECONCILIATION_VERSION{1};
|
||||
inline constexpr uint32_t TXRECONCILIATION_VERSION{1};
|
||||
|
||||
enum class ReconciliationRegisterResult {
|
||||
NOT_FOUND,
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <string_view>
|
||||
|
||||
// UTXO set snapshot magic bytes
|
||||
static constexpr std::array<uint8_t, 5> SNAPSHOT_MAGIC_BYTES = {'u', 't', 'x', 'o', 0xff};
|
||||
inline constexpr std::array<uint8_t, 5> SNAPSHOT_MAGIC_BYTES = {'u', 't', 'x', 'o', 0xff};
|
||||
|
||||
class Chainstate;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user