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
17inline 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
23inline 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
31{
33 return index.nHeight >= params.DeploymentHeight(dep);
34}
35
36inline 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
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:146
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition: chain.h:152
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:158
BIP 9 allows multiple softforks to be deployed in parallel.
Definition: versionbits.h:79
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.
VersionBitsCache g_versionbitscache
Global cache for versionbits deployment status.
bool DeploymentActiveAfter(const CBlockIndex *pindexPrev, const Consensus::Params &params, Consensus::BuriedDeployment dep)
Determine if a deployment is active for the next block.
bool DeploymentActiveAt(const CBlockIndex &index, const Consensus::Params &params, Consensus::BuriedDeployment dep)
Determine if a deployment is active for this block.
bool DeploymentEnabled(const Consensus::Params &params, Consensus::BuriedDeployment dep)
Determine if a deployment is enabled (can ever be active)
constexpr bool ValidDeployment(BuriedDeployment dep)
Definition: params.h:26
DeploymentPos
Definition: params.h:28
BuriedDeployment
A buried deployment is one where the height of the activation has been hardcoded into the client impl...
Definition: params.h:18
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
Definition: params.h:64
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
Definition: params.h:43
Parameters that influence chain consensus.
Definition: params.h:70
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
Definition: params.h:98
int DeploymentHeight(BuriedDeployment dep) const
Definition: params.h:118
assert(!tx.IsCoinBase())