20    case ACTIVE: 
return "active";
 
   21    case FAILED: 
return "failed";
 
   32    int64_t nTimeTimeout = 
EndTime();
 
   45    if (pindexPrev != 
nullptr) {
 
   50    std::vector<const CBlockIndex*> vToCompute;
 
   51    while (cache.count(pindexPrev) == 0) {
 
   52        if (pindexPrev == 
nullptr) {
 
   62        vToCompute.push_back(pindexPrev);
 
   67    assert(cache.count(pindexPrev));
 
   71    while (!vToCompute.empty()) {
 
   73        pindexPrev = vToCompute.back();
 
   74        vToCompute.pop_back();
 
   87                for (
int i = 0; i < nPeriod; i++) {
 
   91                    pindexCount = pindexCount->
pprev;
 
   93                if (
count >= nThreshold) {
 
  102                if (pindexPrev->
nHeight + 1 >= min_activation_height) {
 
  113        cache[pindexPrev] = state = stateNext;
 
  126    if (pindex == 
nullptr) 
return stats;
 
  132    if (signalling_blocks) {
 
  133        signalling_blocks->assign(blocks_in_period, 
false);
 
  145            if (signalling_blocks) signalling_blocks->at(blocks_in_period) = 
true;
 
  147        currentIndex = currentIndex->
pprev;
 
  148    } 
while(blocks_in_period > 0);
 
  171    const int nPeriod = 
Period();
 
  183    while (previousPeriodParent != 
nullptr && 
GetStateFor(previousPeriodParent, cache) == initialState) {
 
  184        pindexPrev = previousPeriodParent;
 
  189    return pindexPrev->
nHeight + 1;
 
  203        next_state = checker.
GetStateFor(&block_index, m_caches[
id]);
 
  210    const bool has_signal = (
STARTED == current_state || 
LOCKED_IN == current_state);
 
  214            result.
stats->threshold = 0;
 
  215            result.
stats->possible = 
false;
 
  219    if (current_state == 
ACTIVE) {
 
  221    } 
else if (next_state == 
ACTIVE) {
 
  252            result.
active.try_emplace(vbdepinfo.
name, gbtinfo);
 
  274            nVersion |= checker.
Mask();
 
  303    std::array<ThresholdConditionCache, Consensus::MAX_VERSION_BITS_DEPLOYMENTS>& m_caches;
 
  309    explicit WarningBitsConditionChecker(
const CChainParams& chainparams, std::array<ThresholdConditionCache, Consensus::MAX_VERSION_BITS_DEPLOYMENTS>& caches, 
int bit)
 
  310    : m_params{chainparams.GetConsensus()}, m_caches{caches}, m_bit(bit)
 
  314            threshold = period * 3 / 4; 
 
  318    int64_t 
BeginTime()
 const override { 
return 0; }
 
  319    int64_t 
EndTime()
 const override { 
return std::numeric_limits<int64_t>::max(); }
 
  320    int Period()
 const override { 
return period; }
 
  321    int Threshold()
 const override { 
return threshold; }
 
  327               ((pindex->
nVersion >> m_bit) & 1) != 0 &&
 
  336    std::vector<std::pair<int, bool>> result;
 
  338        WarningBitsConditionChecker checker(chainparams, m_caches, bit);
 
  339        ThresholdState state = checker.GetStateFor(pindex, m_warning_caches.at(bit));
 
  341            result.emplace_back(bit, state == 
ACTIVE);
 
#define Assert(val)
Identity function.
 
Abstract class that implements BIP9-style threshold logic, and caches results.
 
virtual bool Condition(const CBlockIndex *pindex) const =0
 
ThresholdState GetStateFor(const CBlockIndex *pindexPrev, ThresholdConditionCache &cache) const
Returns the state for pindex A based on parent pindexPrev B.
 
int GetStateSinceHeightFor(const CBlockIndex *pindexPrev, ThresholdConditionCache &cache) const
Returns the height since when the ThresholdState has started for pindex A based on parent pindexPrev ...
 
virtual int MinActivationHeight() const
 
BIP9Stats GetStateStatisticsFor(const CBlockIndex *pindex, std::vector< bool > *signalling_blocks=nullptr) const
Returns the numerical statistics of an in-progress BIP9 softfork in the period including pindex If pr...
 
virtual int Period() const =0
 
virtual int Threshold() const =0
 
virtual int64_t BeginTime() const =0
 
virtual int64_t EndTime() const =0
 
The block chain is a tree shaped structure starting with the genesis block at the root,...
 
CBlockIndex * pprev
pointer to the index of the predecessor of this block
 
int64_t GetMedianTimePast() const
 
int32_t nVersion
block header
 
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
 
int nHeight
height of the entry in the chain. The genesis block has height 0
 
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
 
const Consensus::Params & GetConsensus() const
 
bool IsTestChain() const
If this chain is exclusively used for testing.
 
BIP9GBTStatus GBTStatus(const CBlockIndex &block_index, const Consensus::Params ¶ms) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 
int32_t ComputeBlockVersion(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Determine what nVersion a new block should use.
 
std::vector< std::pair< int, bool > > CheckUnknownActivations(const CBlockIndex *pindex, const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Check for unknown activations Returns a vector containing the bit number used for signalling and a bo...
 
BIP9Info Info(const CBlockIndex &block_index, const Consensus::Params ¶ms, Consensus::DeploymentPos id) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 
void Clear() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 
bool IsActiveAfter(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Get the BIP9 state for a given deployment for the block after pindexPrev.
 
Class to implement versionbits logic.
 
const std::array< VBDeploymentInfo, Consensus::MAX_VERSION_BITS_DEPLOYMENTS > VersionBitsDeploymentInfo
 
@ MAX_VERSION_BITS_DEPLOYMENTS
 
std::map< std::string, const Info, std::less<> > signalling
 
std::map< std::string, const Info, std::less<> > active
 
std::map< std::string, const Info, std::less<> > locked_in
 
Detailed status of an enabled BIP9 deployment.
 
std::string current_state
String representing the current state.
 
std::vector< bool > signalling_blocks
Which blocks signalled; empty if signalling is not applicable.
 
int since
Height at which current_state started.
 
std::string next_state
String representing the next block's state.
 
std::optional< BIP9Stats > stats
For states where signalling is applicable, information about the signalling.
 
std::optional< int > active_since
Height at which the deployment is active, if known.
 
Display status of an in-progress BIP9 softfork.
 
uint32_t count
Number of blocks with the version bit set since the beginning of the current period.
 
uint32_t threshold
Number of blocks with the version bit set required to activate the softfork.
 
uint32_t elapsed
Number of blocks elapsed since the beginning of the current period.
 
bool possible
False if there are not enough blocks left in this period to pass activation threshold.
 
uint32_t period
Length of blocks of the BIP9 signalling period.
 
static constexpr int64_t ALWAYS_ACTIVE
Special value for nStartTime indicating that the deployment is always active.
 
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
 
Parameters that influence chain consensus.
 
int64_t DifficultyAdjustmentInterval() const
 
int MinBIP9WarningHeight
Don't warn about unknown BIP 9 activations below this height.
 
std::array< BIP9Deployment, MAX_VERSION_BITS_DEPLOYMENTS > vDeployments
 
bool gbt_optional_rule
Whether GBT clients can safely ignore this rule in simplified usage.
 
const char * name
Deployment name.
 
static int32_t ComputeBlockVersion(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, std::array< ThresholdConditionCache, Consensus::MAX_VERSION_BITS_DEPLOYMENTS > &caches)
 
std::string StateName(ThresholdState state)
Get a string with the state name.
 
std::map< const CBlockIndex *, ThresholdState > ThresholdConditionCache
 
static const int32_t VERSIONBITS_NUM_BITS
Total bits available for versionbits.
 
static const int32_t VERSIONBITS_TOP_BITS
What bits to set in version for versionbits blocks.
 
static const int32_t VERSIONBITS_TOP_MASK
What bitmask determines whether versionbits is in use.
 
ThresholdState
BIP 9 defines a finite-state-machine to deploy a softfork in multiple stages.