versionbits: Add support for delayed activation

Github-Pull: #21377
Rebased-From: 73d4a70639
This commit is contained in:
Anthony Towns
2021-03-06 18:18:49 +10:00
committed by Andrew Chow
parent f9517e6014
commit 4cab84cfdf
8 changed files with 41 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex*
{
int nPeriod = Period(params);
int nThreshold = Threshold(params);
int min_activation_height = MinActivationHeight(params);
int64_t nTimeStart = BeginTime(params);
int64_t nTimeTimeout = EndTime(params);
@@ -78,8 +79,10 @@ ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex*
break;
}
case ThresholdState::LOCKED_IN: {
// Always progresses into ACTIVE.
stateNext = ThresholdState::ACTIVE;
// Progresses into ACTIVE provided activation height will have been reached.
if (pindexPrev->nHeight + 1 >= min_activation_height) {
stateNext = ThresholdState::ACTIVE;
}
break;
}
case ThresholdState::FAILED:
@@ -170,6 +173,7 @@ private:
protected:
int64_t BeginTime(const Consensus::Params& params) const override { return params.vDeployments[id].nStartTime; }
int64_t EndTime(const Consensus::Params& params) const override { return params.vDeployments[id].nTimeout; }
int MinActivationHeight(const Consensus::Params& params) const override { return params.vDeployments[id].min_activation_height; }
int Period(const Consensus::Params& params) const override { return params.nMinerConfirmationWindow; }
int Threshold(const Consensus::Params& params) const override { return params.nRuleChangeActivationThreshold; }