aboutsummaryrefslogtreecommitdiff
path: root/src/versionbits.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-04-07 10:20:46 +1000
committerAndrew Chow <achow101-github@achow101.com>2021-04-15 20:59:17 -0400
commit600357306e2e182a457174862ea2e41c7ba39c64 (patch)
tree693bb010f1d57671469e536456356d3149de8d64 /src/versionbits.cpp
parent3acf0379e0979ea4bdd03976f4987aa6711eb92f (diff)
downloadbitcoin-600357306e2e182a457174862ea2e41c7ba39c64.tar.xz
versionbits: simplify state transitions
This removes the DEFINED->FAILED transition and changes the STARTED->FAILED transition to only occur if signalling didn't pass the threshold. This ensures that it is always possible for activation to occur, no matter what settings are chosen, or the speed at which blocks are found. Github-Pull: #21377 Rebased-From: f054f6bcd2c2ce5fea84cf8681013f85a444e7ea
Diffstat (limited to 'src/versionbits.cpp')
-rw-r--r--src/versionbits.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/versionbits.cpp b/src/versionbits.cpp
index df666c963f..df2ec4e056 100644
--- a/src/versionbits.cpp
+++ b/src/versionbits.cpp
@@ -57,18 +57,12 @@ ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex*
switch (state) {
case ThresholdState::DEFINED: {
- if (pindexPrev->GetMedianTimePast() >= nTimeTimeout) {
- stateNext = ThresholdState::FAILED;
- } else if (pindexPrev->GetMedianTimePast() >= nTimeStart) {
+ if (pindexPrev->GetMedianTimePast() >= nTimeStart) {
stateNext = ThresholdState::STARTED;
}
break;
}
case ThresholdState::STARTED: {
- if (pindexPrev->GetMedianTimePast() >= nTimeTimeout) {
- stateNext = ThresholdState::FAILED;
- break;
- }
// We need to count
const CBlockIndex* pindexCount = pindexPrev;
int count = 0;
@@ -80,6 +74,8 @@ ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex*
}
if (count >= nThreshold) {
stateNext = ThresholdState::LOCKED_IN;
+ } else if (pindexPrev->GetMedianTimePast() >= nTimeTimeout) {
+ stateNext = ThresholdState::FAILED;
}
break;
}