Bitcoin Core  22.99.0
P2P Digital Currency
deploymentstatus.h
Go to the documentation of this file.
1 // Copyright (c) 2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_DEPLOYMENTSTATUS_H
6 #define BITCOIN_DEPLOYMENTSTATUS_H
7 
8 #include <chain.h>
9 #include <versionbits.h>
10 
11 #include <limits>
12 
15 
17 inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::BuriedDeployment dep)
18 {
20  return (pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1) >= params.DeploymentHeight(dep);
21 }
22 
23 inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos dep)
24 {
26  return ThresholdState::ACTIVE == g_versionbitscache.State(pindexPrev, params, dep);
27 }
28 
30 inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::BuriedDeployment dep)
31 {
33  return index.nHeight >= params.DeploymentHeight(dep);
34 }
35 
36 inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::DeploymentPos dep)
37 {
39  return DeploymentActiveAfter(index.pprev, params, dep);
40 }
41 
44 {
46  return params.DeploymentHeight(dep) != std::numeric_limits<int>::max();
47 }
48 
50 {
53 }
54 
55 #endif // BITCOIN_DEPLOYMENTSTATUS_H
Consensus::BIP9Deployment::nStartTime
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
Definition: params.h:43
ThresholdState::ACTIVE
@ ACTIVE
assert
assert(!tx.IsCoinBase())
VersionBitsCache::State
ThresholdState State(const CBlockIndex *pindexPrev, const Consensus::Params &params, Consensus::DeploymentPos pos)
Get the BIP9 state for a given deployment for the block after pindexPrev.
Definition: versionbits.cpp:193
CBlockIndex::pprev
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition: chain.h:144
DeploymentActiveAfter
bool DeploymentActiveAfter(const CBlockIndex *pindexPrev, const Consensus::Params &params, Consensus::BuriedDeployment dep)
Determine if a deployment is active for the next block.
Definition: deploymentstatus.h:17
CBlockIndex::nHeight
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:150
Consensus::Params
Parameters that influence chain consensus.
Definition: params.h:70
Consensus::DeploymentPos
DeploymentPos
Definition: params.h:28
g_versionbitscache
VersionBitsCache g_versionbitscache
Global cache for versionbits deployment status.
Definition: deploymentstatus.cpp:12
DeploymentEnabled
bool DeploymentEnabled(const Consensus::Params &params, Consensus::BuriedDeployment dep)
Determine if a deployment is enabled (can ever be active)
Definition: deploymentstatus.h:43
DeploymentActiveAt
bool DeploymentActiveAt(const CBlockIndex &index, const Consensus::Params &params, Consensus::BuriedDeployment dep)
Determine if a deployment is active for this block.
Definition: deploymentstatus.h:30
Consensus::ValidDeployment
constexpr bool ValidDeployment(BuriedDeployment dep)
Definition: params.h:26
Consensus::BIP9Deployment::NEVER_ACTIVE
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
Definition: params.h:64
versionbits.h
chain.h
Consensus::Params::vDeployments
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
Definition: params.h:98
Consensus::Params::DeploymentHeight
int DeploymentHeight(BuriedDeployment dep) const
Definition: params.h:118
Consensus::BuriedDeployment
BuriedDeployment
A buried deployment is one where the height of the activation has been hardcoded into the client impl...
Definition: params.h:18
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:137
VersionBitsCache
BIP 9 allows multiple softforks to be deployed in parallel.
Definition: versionbits.h:78