aboutsummaryrefslogtreecommitdiff
path: root/src/versionbits.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-03-27 23:00:14 +1000
committerAndrew Chow <achow101-github@achow101.com>2021-04-15 20:59:13 -0400
commit3acf0379e0979ea4bdd03976f4987aa6711eb92f (patch)
tree03f6ae026ba46234871db7ba08f789d67f60620d /src/versionbits.cpp
parentb529222ad18f7facbaff394455875b4aa65d653e (diff)
downloadbitcoin-3acf0379e0979ea4bdd03976f4987aa6711eb92f.tar.xz
versionbits: Add explicit NEVER_ACTIVE deployments
Previously we used deployments that would timeout prior to Bitcoin's invention, which allowed the deployment to still be activated in unit tests. This switches those deployments to be truly never active. Github-Pull: #21377 Rebased-From: 55ac5f568a3b73d6f1ef4654617fb76e8bcbccdf
Diffstat (limited to 'src/versionbits.cpp')
-rw-r--r--src/versionbits.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/versionbits.cpp b/src/versionbits.cpp
index 11da729596..df666c963f 100644
--- a/src/versionbits.cpp
+++ b/src/versionbits.cpp
@@ -18,6 +18,11 @@ ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex*
return ThresholdState::ACTIVE;
}
+ // Check if this deployment is never active.
+ if (nTimeStart == Consensus::BIP9Deployment::NEVER_ACTIVE) {
+ return ThresholdState::FAILED;
+ }
+
// A block's state is always the same as that of the first of its period, so it is computed based on a pindexPrev whose height equals a multiple of nPeriod - 1.
if (pindexPrev != nullptr) {
pindexPrev = pindexPrev->GetAncestor(pindexPrev->nHeight - ((pindexPrev->nHeight + 1) % nPeriod));
@@ -129,7 +134,7 @@ BIP9Stats AbstractThresholdConditionChecker::GetStateStatisticsFor(const CBlockI
int AbstractThresholdConditionChecker::GetStateSinceHeightFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const
{
int64_t start_time = BeginTime(params);
- if (start_time == Consensus::BIP9Deployment::ALWAYS_ACTIVE) {
+ if (start_time == Consensus::BIP9Deployment::ALWAYS_ACTIVE || start_time == Consensus::BIP9Deployment::NEVER_ACTIVE) {
return 0;
}