Skip to content

Commit 98f4bda

Browse files
committed
refactor: Convert warningcache to std::array
1 parent bd616bc commit 98f4bda

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/validation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker
19211921
}
19221922
};
19231923

1924-
static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS] GUARDED_BY(cs_main);
1924+
static std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> warningcache GUARDED_BY(cs_main);
19251925

19261926
static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Consensus::Params& consensusparams)
19271927
{
@@ -2550,7 +2550,7 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew)
25502550
const CBlockIndex* pindex = pindexNew;
25512551
for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) {
25522552
WarningBitsConditionChecker checker(bit);
2553-
ThresholdState state = checker.GetStateFor(pindex, m_params.GetConsensus(), warningcache[bit]);
2553+
ThresholdState state = checker.GetStateFor(pindex, m_params.GetConsensus(), warningcache.at(bit));
25542554
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
25552555
const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
25562556
if (state == ThresholdState::ACTIVE) {
@@ -4152,8 +4152,8 @@ void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman)
41524152
chainman.Unload();
41534153
if (mempool) mempool->clear();
41544154
g_versionbitscache.Clear();
4155-
for (int b = 0; b < VERSIONBITS_NUM_BITS; b++) {
4156-
warningcache[b].clear();
4155+
for (auto& i : warningcache) {
4156+
i.clear();
41574157
}
41584158
}
41594159

0 commit comments

Comments
 (0)