diff --git a/src/chainparams.cpp b/src/chainparams.cpp --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -98,17 +98,17 @@ consensus.fPowAllowMinDifficultyBlocks = false; consensus.fPowNoRetargeting = false; - // 95% of 2016 - consensus.nRuleChangeActivationThreshold = 1916; // nPowTargetTimespan / nPowTargetSpacing consensus.nMinerConfirmationWindow = 2016; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; - // January 1, 2008 - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = - 1199145601; - // December 31, 2008 - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = - 1230767999; + consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = { + .bit = 28, + // 95% of 2016 + .nActivationThreshold = 1916, + // January 1, 2008 + .nStartTime = 1199145601, + // December 31, 2008 + .nTimeout = 1230767999, + }; // The best chain should have at least this much work. consensus.nMinimumChainWork = @@ -250,7 +250,8 @@ // (the tx=... number in the ChainStateFlushed debug.log lines) 248589038, // Estimated number of transactions per second after that timestamp. - 3.2}; + 3.2, + }; } }; @@ -281,17 +282,15 @@ consensus.fPowAllowMinDifficultyBlocks = true; consensus.fPowNoRetargeting = false; - // 75% for testchains - consensus.nRuleChangeActivationThreshold = 1512; // nPowTargetTimespan / nPowTargetSpacing consensus.nMinerConfirmationWindow = 2016; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; - // January 1, 2008 - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = - 1199145601; - // December 31, 2008 - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = - 1230767999; + consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = { + .bit = 28, + // January 1, 2008 + .nStartTime = 1199145601, + // December 31, 2008 + .nTimeout = 1230767999, + }; // The best chain should have at least this much work. consensus.nMinimumChainWork = @@ -422,14 +421,13 @@ consensus.fPowAllowMinDifficultyBlocks = true; consensus.fPowNoRetargeting = true; - // 75% for testchains - consensus.nRuleChangeActivationThreshold = 108; // Faster than normal for regtest (144 instead of 2016) consensus.nMinerConfirmationWindow = 144; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = - Consensus::BIP9Deployment::NO_TIMEOUT; + consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = { + .bit = 28, + // 75% of 144 + .nActivationThreshold = 108, + }; // The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x00"); diff --git a/src/consensus/params.h b/src/consensus/params.h --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -26,13 +26,19 @@ struct BIP9Deployment { /** Bit position to select the particular bit in nVersion. */ int bit; + /** + * Minimum number of blocks within an activation window that must signal to + * activate the deployement. + * Default to 75% of 2016. + */ + uint32_t nActivationThreshold = 1512; /** * Start MedianTime for version bits miner confirmation. Can be a date in * the past. */ - int64_t nStartTime; + int64_t nStartTime = 0; /** Timeout/expiry MedianTime for the deployment attempt. */ - int64_t nTimeout; + int64_t nTimeout = NO_TIMEOUT; /** Constant for nTimeout very far in the future. */ static constexpr int64_t NO_TIMEOUT = std::numeric_limits::max(); @@ -80,13 +86,6 @@ * This prevents us from warning about the CSV and segwit activations. */ int MinBIP9WarningHeight; - /** - * Minimum blocks including miner confirmation of the total of 2016 blocks - * in a retargeting period, (nPowTargetTimespan / nPowTargetSpacing) which - * is also used for BIP9 deployments. Examples: 1916 for 95%, 1512 for - * testchains. - */ - uint32_t nRuleChangeActivationThreshold; uint32_t nMinerConfirmationWindow; BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]; diff --git a/src/versionbits.cpp b/src/versionbits.cpp --- a/src/versionbits.cpp +++ b/src/versionbits.cpp @@ -196,7 +196,7 @@ return params.nMinerConfirmationWindow; } int Threshold(const Consensus::Params ¶ms) const override { - return params.nRuleChangeActivationThreshold; + return params.vDeployments[id].nActivationThreshold; } bool Condition(const CBlockIndex *pindex,