Bitcoin Core  27.99.0
P2P Digital Currency
deploymentstatus.h
Go to the documentation of this file.
1 // Copyright (c) 2020-2022 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 
14 inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::BuriedDeployment dep, [[maybe_unused]] VersionBitsCache& versionbitscache)
15 {
17  return (pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1) >= params.DeploymentHeight(dep);
18 }
19 
20 inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos dep, VersionBitsCache& versionbitscache)
21 {
23  return ThresholdState::ACTIVE == versionbitscache.State(pindexPrev, params, dep);
24 }
25 
27 inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::BuriedDeployment dep, [[maybe_unused]] VersionBitsCache& versionbitscache)
28 {
30  return index.nHeight >= params.DeploymentHeight(dep);
31 }
32 
33 inline bool DeploymentActiveAt(const CBlockIndex& index, const Consensus::Params& params, Consensus::DeploymentPos dep, VersionBitsCache& versionbitscache)
34 {
36  return DeploymentActiveAfter(index.pprev, params, dep, versionbitscache);
37 }
38 
41 {
43  return params.DeploymentHeight(dep) != std::numeric_limits<int>::max();
44 }
45 
47 {
50 }
51 
52 #endif // BITCOIN_DEPLOYMENTSTATUS_H
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:141
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition: chain.h:147
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:153
BIP 9 allows multiple softforks to be deployed in parallel.
Definition: versionbits.h:81
ThresholdState State(const CBlockIndex *pindexPrev, const Consensus::Params &params, Consensus::DeploymentPos pos) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Get the BIP9 state for a given deployment for the block after pindexPrev.
bool DeploymentActiveAfter(const CBlockIndex *pindexPrev, const Consensus::Params &params, Consensus::BuriedDeployment dep, [[maybe_unused]] VersionBitsCache &versionbitscache)
Determine if a deployment is active for the next block.
bool DeploymentEnabled(const Consensus::Params &params, Consensus::BuriedDeployment dep)
Determine if a deployment is enabled (can ever be active)
bool DeploymentActiveAt(const CBlockIndex &index, const Consensus::Params &params, Consensus::BuriedDeployment dep, [[maybe_unused]] VersionBitsCache &versionbitscache)
Determine if a deployment is active for this block.
constexpr bool ValidDeployment(BuriedDeployment dep)
Definition: params.h:30
DeploymentPos
Definition: params.h:32
BuriedDeployment
A buried deployment is one where the height of the activation has been hardcoded into the client impl...
Definition: params.h:22
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
Definition: params.h:68
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
Definition: params.h:47
Parameters that influence chain consensus.
Definition: params.h:74
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
Definition: params.h:107
int DeploymentHeight(BuriedDeployment dep) const
Definition: params.h:131
assert(!tx.IsCoinBase())