diff options
author | Anthony Towns <aj@erisian.com.au> | 2020-06-16 18:58:56 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2021-06-29 17:11:12 +1000 |
commit | 2b0d291da8f479739ff394dd92801da8c40b9f8e (patch) | |
tree | 50968fbedda38d56cfd6fa5b1a7c2a3ee037ddab /src/consensus/params.h | |
parent | eccd736f3dc231ac0306ca763c3b72cf8247230a (diff) | |
download | bitcoin-2b0d291da8f479739ff394dd92801da8c40b9f8e.tar.xz |
[refactor] Add deploymentstatus.h
Provides DeploymentEnabled, DeploymentActiveAt, and DeploymentActiveAfter
helpers for checking the status of buried deployments. Can be overloaded
so the same syntax works for non-buried deployments, allowing future
soft forks to be changed from signalled to buried deployments without
having to touch the implementation code.
Replaces IsWitnessEnabled and IsScriptWitnessEnabled.
Diffstat (limited to 'src/consensus/params.h')
-rw-r--r-- | src/consensus/params.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/consensus/params.h b/src/consensus/params.h index 28c95e0884..9b4139d76c 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -11,6 +11,17 @@ namespace Consensus { +enum BuriedDeployment : int16_t +{ + // buried deployments get negative values to avoid overlap with DeploymentPos + DEPLOYMENT_HEIGHTINCB = std::numeric_limits<int16_t>::min(), + DEPLOYMENT_CLTV, + DEPLOYMENT_DERSIG, + DEPLOYMENT_CSV, + DEPLOYMENT_SEGWIT, +}; +constexpr bool ValidDeployment(BuriedDeployment dep) { return DEPLOYMENT_HEIGHTINCB <= dep && dep <= DEPLOYMENT_SEGWIT; } + enum DeploymentPos { DEPLOYMENT_TESTDUMMY, @@ -100,7 +111,25 @@ struct Params { */ bool signet_blocks{false}; std::vector<uint8_t> signet_challenge; + + int DeploymentHeight(BuriedDeployment dep) const + { + switch (dep) { + case DEPLOYMENT_HEIGHTINCB: + return BIP34Height; + case DEPLOYMENT_CLTV: + return BIP65Height; + case DEPLOYMENT_DERSIG: + return BIP66Height; + case DEPLOYMENT_CSV: + return CSVHeight; + case DEPLOYMENT_SEGWIT: + return SegwitHeight; + } // no default case, so the compiler can warn about missing cases + return std::numeric_limits<int>::max(); + } }; + } // namespace Consensus #endif // BITCOIN_CONSENSUS_PARAMS_H |