diff --git a/src/test/versionbits_tests.cpp b/src/test/versionbits_tests.cpp --- a/src/test/versionbits_tests.cpp +++ b/src/test/versionbits_tests.cpp @@ -114,7 +114,7 @@ BOOST_CHECK_MESSAGE( checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == - THRESHOLD_DEFINED, + ThresholdState::DEFINED, strprintf("Test %i for DEFINED", num)); } } @@ -128,7 +128,7 @@ BOOST_CHECK_MESSAGE( checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == - THRESHOLD_STARTED, + ThresholdState::STARTED, strprintf("Test %i for STARTED", num)); } } @@ -142,7 +142,7 @@ BOOST_CHECK_MESSAGE( checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == - THRESHOLD_LOCKED_IN, + ThresholdState::LOCKED_IN, strprintf("Test %i for LOCKED_IN", num)); } } @@ -156,7 +156,7 @@ BOOST_CHECK_MESSAGE( checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == - THRESHOLD_ACTIVE, + ThresholdState::ACTIVE, strprintf("Test %i for ACTIVE", num)); } } @@ -170,7 +170,7 @@ BOOST_CHECK_MESSAGE( checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == - THRESHOLD_FAILED, + ThresholdState::FAILED, strprintf("Test %i for FAILED", num)); } } diff --git a/src/versionbits.h b/src/versionbits.h --- a/src/versionbits.h +++ b/src/versionbits.h @@ -17,12 +17,12 @@ /** Total bits available for versionbits */ static const int32_t VERSIONBITS_NUM_BITS = 29; -enum ThresholdState { - THRESHOLD_DEFINED, - THRESHOLD_STARTED, - THRESHOLD_LOCKED_IN, - THRESHOLD_ACTIVE, - THRESHOLD_FAILED, +enum class ThresholdState { + DEFINED, + STARTED, + LOCKED_IN, + ACTIVE, + FAILED, }; // A map that gives the state for blocks whose height is a multiple of Period(). diff --git a/src/versionbits.cpp b/src/versionbits.cpp --- a/src/versionbits.cpp +++ b/src/versionbits.cpp @@ -36,13 +36,13 @@ while (cache.count(pindexPrev) == 0) { if (pindexPrev == nullptr) { // The genesis block is by definition defined. - cache[pindexPrev] = THRESHOLD_DEFINED; + cache[pindexPrev] = ThresholdState::DEFINED; break; } if (pindexPrev->GetMedianTimePast() < nTimeStart) { // Optimization: don't recompute down further, as we know every // earlier block will be before the start time - cache[pindexPrev] = THRESHOLD_DEFINED; + cache[pindexPrev] = ThresholdState::DEFINED; break; } vToCompute.push_back(pindexPrev); @@ -60,17 +60,17 @@ vToCompute.pop_back(); switch (state) { - case THRESHOLD_DEFINED: { + case ThresholdState::DEFINED: { if (pindexPrev->GetMedianTimePast() >= nTimeTimeout) { - stateNext = THRESHOLD_FAILED; + stateNext = ThresholdState::FAILED; } else if (pindexPrev->GetMedianTimePast() >= nTimeStart) { - stateNext = THRESHOLD_STARTED; + stateNext = ThresholdState::STARTED; } break; } - case THRESHOLD_STARTED: { + case ThresholdState::STARTED: { if (pindexPrev->GetMedianTimePast() >= nTimeTimeout) { - stateNext = THRESHOLD_FAILED; + stateNext = ThresholdState::FAILED; break; } // We need to count @@ -83,17 +83,17 @@ pindexCount = pindexCount->pprev; } if (count >= nThreshold) { - stateNext = THRESHOLD_LOCKED_IN; + stateNext = ThresholdState::LOCKED_IN; } break; } - case THRESHOLD_LOCKED_IN: { + case ThresholdState::LOCKED_IN: { // Always progresses into ACTIVE. - stateNext = THRESHOLD_ACTIVE; + stateNext = ThresholdState::ACTIVE; break; } - case THRESHOLD_FAILED: - case THRESHOLD_ACTIVE: { + case ThresholdState::FAILED: + case ThresholdState::ACTIVE: { // Nothing happens, these are terminal states. break; } @@ -111,7 +111,7 @@ // BIP 9 about state DEFINED: "The genesis block is by definition in this // state for each deployment." - if (initialState == THRESHOLD_DEFINED) { + if (initialState == ThresholdState::DEFINED) { return 0; }