Skip to content

Commit 97153a7

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22385: refactor: Use DeploymentEnabled to hide VB deployments
fa5658e Use DeploymentEnabled to hide VB deployments (MarcoFalke) fa11fec doc: Move buried deployment doc to the enum that enumerates them (MarcoFalke) Pull request description: Plus a doc commit. ACKs for top commit: jnewbery: utACK fa5658e ajtowns: utACK fa5658e Tree-SHA512: 2aeceee0674feb603d76656eff40695b7d7305de309f837bbb6a8c1dbb1d0b962b741f06ab7b9a8b1dbd1964c9c0c9aa5dc9588fd8e6d896e620b69e08eedbaa
2 parents e2c4ac7 + fa5658e commit 97153a7

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/consensus/params.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111

1212
namespace Consensus {
1313

14-
enum BuriedDeployment : int16_t
15-
{
14+
/**
15+
* A buried deployment is one where the height of the activation has been hardcoded into
16+
* the client implementation long after the consensus change has activated. See BIP 90.
17+
*/
18+
enum BuriedDeployment : int16_t {
1619
// buried deployments get negative values to avoid overlap with DeploymentPos
1720
DEPLOYMENT_HEIGHTINCB = std::numeric_limits<int16_t>::min(),
1821
DEPLOYMENT_CLTV,
@@ -22,8 +25,7 @@ enum BuriedDeployment : int16_t
2225
};
2326
constexpr bool ValidDeployment(BuriedDeployment dep) { return DEPLOYMENT_HEIGHTINCB <= dep && dep <= DEPLOYMENT_SEGWIT; }
2427

25-
enum DeploymentPos : uint16_t
26-
{
28+
enum DeploymentPos : uint16_t {
2729
DEPLOYMENT_TESTDUMMY,
2830
DEPLOYMENT_TAPROOT, // Deployment of Schnorr/Taproot (BIPs 340-342)
2931
// NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp

src/deploymentstatus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::Buried
4949
inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::DeploymentPos dep)
5050
{
5151
assert(Consensus::ValidDeployment(dep));
52-
return params.vDeployments[dep].nTimeout != 0;
52+
return params.vDeployments[dep].nStartTime != Consensus::BIP9Deployment::NEVER_ACTIVE;
5353
}
5454

5555
#endif // BITCOIN_DEPLOYMENTSTATUS_H

src/rpc/blockchain.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,10 +1350,7 @@ static RPCHelpMan verifychain()
13501350
static void SoftForkDescPushBack(const CBlockIndex* active_chain_tip, UniValue& softforks, const Consensus::Params& params, Consensus::BuriedDeployment dep)
13511351
{
13521352
// For buried deployments.
1353-
// A buried deployment is one where the height of the activation has been hardcoded into
1354-
// the client implementation long after the consensus change has activated. See BIP 90.
1355-
// Buried deployments with activation height value of
1356-
// std::numeric_limits<int>::max() are disabled and thus hidden.
1353+
13571354
if (!DeploymentEnabled(params, dep)) return;
13581355

13591356
UniValue rv(UniValue::VOBJ);
@@ -1368,8 +1365,8 @@ static void SoftForkDescPushBack(const CBlockIndex* active_chain_tip, UniValue&
13681365
static void SoftForkDescPushBack(const CBlockIndex* active_chain_tip, UniValue& softforks, const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
13691366
{
13701367
// For BIP9 deployments.
1371-
// Deployments that are never active are hidden.
1372-
if (consensusParams.vDeployments[id].nStartTime == Consensus::BIP9Deployment::NEVER_ACTIVE) return;
1368+
1369+
if (!DeploymentEnabled(consensusParams, id)) return;
13731370

13741371
UniValue bip9(UniValue::VOBJ);
13751372
const ThresholdState thresholdState = g_versionbitscache.State(active_chain_tip, consensusParams, id);

0 commit comments

Comments
 (0)