mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-07-24 15:18:51 +02:00
chainparams: encapsulate deployment configuration logic
This encapsulates the soft fork configuration logic as set by the `-testactivationheight` (for buried deployments) and `-vbparams` (for version bits deployments) options which for the moment are regtest-only, in order to make them available on other networks as well in the next commit. Can be reviewed using git's `--color-moved` option with `--color-moved-ws=allow-indentation-change`.
This commit is contained in:
committed by
Antoine Poinsot
parent
b796bf44f3
commit
df7ed5f355
@@ -72,6 +72,35 @@ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits
|
||||
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
|
||||
}
|
||||
|
||||
void CChainParams::ApplyDeploymentOptions(const DeploymentOptions& opts)
|
||||
{
|
||||
for (const auto& [dep, height] : opts.activation_heights) {
|
||||
switch (dep) {
|
||||
case Consensus::BuriedDeployment::DEPLOYMENT_SEGWIT:
|
||||
consensus.SegwitHeight = int{height};
|
||||
break;
|
||||
case Consensus::BuriedDeployment::DEPLOYMENT_HEIGHTINCB:
|
||||
consensus.BIP34Height = int{height};
|
||||
break;
|
||||
case Consensus::BuriedDeployment::DEPLOYMENT_DERSIG:
|
||||
consensus.BIP66Height = int{height};
|
||||
break;
|
||||
case Consensus::BuriedDeployment::DEPLOYMENT_CLTV:
|
||||
consensus.BIP65Height = int{height};
|
||||
break;
|
||||
case Consensus::BuriedDeployment::DEPLOYMENT_CSV:
|
||||
consensus.CSVHeight = int{height};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& [deployment_pos, version_bits_params] : opts.version_bits_parameters) {
|
||||
consensus.vDeployments[deployment_pos].nStartTime = version_bits_params.start_time;
|
||||
consensus.vDeployments[deployment_pos].nTimeout = version_bits_params.timeout;
|
||||
consensus.vDeployments[deployment_pos].min_activation_height = version_bits_params.min_activation_height;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Main network on which people trade goods and services.
|
||||
*/
|
||||
@@ -566,31 +595,7 @@ public:
|
||||
m_assumed_blockchain_size = 0;
|
||||
m_assumed_chain_state_size = 0;
|
||||
|
||||
for (const auto& [dep, height] : opts.activation_heights) {
|
||||
switch (dep) {
|
||||
case Consensus::BuriedDeployment::DEPLOYMENT_SEGWIT:
|
||||
consensus.SegwitHeight = int{height};
|
||||
break;
|
||||
case Consensus::BuriedDeployment::DEPLOYMENT_HEIGHTINCB:
|
||||
consensus.BIP34Height = int{height};
|
||||
break;
|
||||
case Consensus::BuriedDeployment::DEPLOYMENT_DERSIG:
|
||||
consensus.BIP66Height = int{height};
|
||||
break;
|
||||
case Consensus::BuriedDeployment::DEPLOYMENT_CLTV:
|
||||
consensus.BIP65Height = int{height};
|
||||
break;
|
||||
case Consensus::BuriedDeployment::DEPLOYMENT_CSV:
|
||||
consensus.CSVHeight = int{height};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& [deployment_pos, version_bits_params] : opts.version_bits_parameters) {
|
||||
consensus.vDeployments[deployment_pos].nStartTime = version_bits_params.start_time;
|
||||
consensus.vDeployments[deployment_pos].nTimeout = version_bits_params.timeout;
|
||||
consensus.vDeployments[deployment_pos].min_activation_height = version_bits_params.min_activation_height;
|
||||
}
|
||||
ApplyDeploymentOptions(opts.dep_opts);
|
||||
|
||||
genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
|
||||
consensus.hashGenesisBlock = genesis.GetHash();
|
||||
|
||||
Reference in New Issue
Block a user