From 9bc41f1b48b2e0cc6abf9714e860a29989d7809c Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Thu, 7 Dec 2023 09:20:03 +1000 Subject: [PATCH] versionbits: Use std::array instead of C-style arrays --- src/consensus/params.h | 3 ++- src/deploymentinfo.cpp | 14 +++++++------- src/deploymentinfo.h | 3 ++- src/versionbits.h | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/consensus/params.h b/src/consensus/params.h index dd29b9408e2..32f14c25e84 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -104,7 +105,7 @@ struct Params { */ uint32_t nRuleChangeActivationThreshold; uint32_t nMinerConfirmationWindow; - BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]; + std::array vDeployments; /** Proof of work parameters */ uint256 powLimit; bool fPowAllowMinDifficultyBlocks; diff --git a/src/deploymentinfo.cpp b/src/deploymentinfo.cpp index 185a7dcb54c..0931ec77d37 100644 --- a/src/deploymentinfo.cpp +++ b/src/deploymentinfo.cpp @@ -8,14 +8,14 @@ #include -const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] = { - { - /*.name =*/ "testdummy", - /*.gbt_force =*/ true, +const std::array VersionBitsDeploymentInfo{ + VBDeploymentInfo{ + .name = "testdummy", + .gbt_force = true, }, - { - /*.name =*/ "taproot", - /*.gbt_force =*/ true, + VBDeploymentInfo{ + .name = "taproot", + .gbt_force = true, }, }; diff --git a/src/deploymentinfo.h b/src/deploymentinfo.h index 72ba297ea0b..b6ca4450f41 100644 --- a/src/deploymentinfo.h +++ b/src/deploymentinfo.h @@ -7,6 +7,7 @@ #include +#include #include #include @@ -17,7 +18,7 @@ struct VBDeploymentInfo { bool gbt_force; }; -extern const VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]; +extern const std::array VersionBitsDeploymentInfo; std::string DeploymentName(Consensus::BuriedDeployment dep); diff --git a/src/versionbits.h b/src/versionbits.h index 09313d2054a..8d2cd0f43d4 100644 --- a/src/versionbits.h +++ b/src/versionbits.h @@ -8,6 +8,7 @@ #include #include +#include #include /** What block version to use for new blocks (pre versionbits) */ @@ -81,7 +82,7 @@ class VersionBitsCache { private: Mutex m_mutex; - ThresholdConditionCache m_caches[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] GUARDED_BY(m_mutex); + std::array m_caches GUARDED_BY(m_mutex); public: /** Get the numerical statistics for a given deployment for the signalling period that includes pindex.