Bitcoin Core 29.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
14inline 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
20inline bool DeploymentActiveAfter(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos dep, VersionBitsCache& versionbitscache)
21{
23 return versionbitscache.IsActiveAfter(pindexPrev, params, dep);
24}
25
27inline 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
33inline 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{
49 return params.vDeployments[dep].nStartTime != Consensus::BIP9Deployment::NEVER_ACTIVE;
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:77
bool IsActiveAfter(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, 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, VersionBitsCache &versionbitscache)
Determine if a deployment is active for this block.
constexpr bool ValidDeployment(BuriedDeployment dep)
Definition: params.h:31
DeploymentPos
Definition: params.h:33
BuriedDeployment
A buried deployment is one where the height of the activation has been hardcoded into the client impl...
Definition: params.h:23
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
Definition: params.h:77
Parameters that influence chain consensus.
Definition: params.h:83
int DeploymentHeight(BuriedDeployment dep) const
Definition: params.h:138
std::array< BIP9Deployment, MAX_VERSION_BITS_DEPLOYMENTS > vDeployments
Definition: params.h:109
assert(!tx.IsCoinBase())