Skip to content

Commit 9bc41f1

Browse files
committed
versionbits: Use std::array instead of C-style arrays
1 parent fa0c473 commit 9bc41f1

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/consensus/params.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <uint256.h>
1010

11+
#include <array>
1112
#include <chrono>
1213
#include <limits>
1314
#include <map>
@@ -104,7 +105,7 @@ struct Params {
104105
*/
105106
uint32_t nRuleChangeActivationThreshold;
106107
uint32_t nMinerConfirmationWindow;
107-
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS];
108+
std::array<BIP9Deployment,MAX_VERSION_BITS_DEPLOYMENTS> vDeployments;
108109
/** Proof of work parameters */
109110
uint256 powLimit;
110111
bool fPowAllowMinDifficultyBlocks;

src/deploymentinfo.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
#include <string_view>
1010

11-
const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] = {
12-
{
13-
/*.name =*/ "testdummy",
14-
/*.gbt_force =*/ true,
11+
const std::array<VBDeploymentInfo,Consensus::MAX_VERSION_BITS_DEPLOYMENTS> VersionBitsDeploymentInfo{
12+
VBDeploymentInfo{
13+
.name = "testdummy",
14+
.gbt_force = true,
1515
},
16-
{
17-
/*.name =*/ "taproot",
18-
/*.gbt_force =*/ true,
16+
VBDeploymentInfo{
17+
.name = "taproot",
18+
.gbt_force = true,
1919
},
2020
};
2121

src/deploymentinfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <consensus/params.h>
99

10+
#include <array>
1011
#include <optional>
1112
#include <string>
1213

@@ -17,7 +18,7 @@ struct VBDeploymentInfo {
1718
bool gbt_force;
1819
};
1920

20-
extern const VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS];
21+
extern const std::array<VBDeploymentInfo,Consensus::MAX_VERSION_BITS_DEPLOYMENTS> VersionBitsDeploymentInfo;
2122

2223
std::string DeploymentName(Consensus::BuriedDeployment dep);
2324

src/versionbits.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <chain.h>
99
#include <sync.h>
1010

11+
#include <array>
1112
#include <map>
1213

1314
/** What block version to use for new blocks (pre versionbits) */
@@ -81,7 +82,7 @@ class VersionBitsCache
8182
{
8283
private:
8384
Mutex m_mutex;
84-
ThresholdConditionCache m_caches[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] GUARDED_BY(m_mutex);
85+
std::array<ThresholdConditionCache,Consensus::MAX_VERSION_BITS_DEPLOYMENTS> m_caches GUARDED_BY(m_mutex);
8586

8687
public:
8788
/** Get the numerical statistics for a given deployment for the signalling period that includes pindex.

0 commit comments

Comments
 (0)