5#ifndef BITCOIN_VERSIONBITS_H
6#define BITCOIN_VERSIONBITS_H
Abstract class that implements BIP9-style threshold logic, and caches results.
virtual bool Condition(const CBlockIndex *pindex, const Consensus::Params ¶ms) const =0
virtual int Period(const Consensus::Params ¶ms) const =0
ThresholdState GetStateFor(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, ThresholdConditionCache &cache) const
Returns the state for pindex A based on parent pindexPrev B.
virtual int64_t EndTime(const Consensus::Params ¶ms) const =0
virtual int MinActivationHeight(const Consensus::Params ¶ms) const
int GetStateSinceHeightFor(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, ThresholdConditionCache &cache) const
Returns the height since when the ThresholdState has started for pindex A based on parent pindexPrev ...
virtual int64_t BeginTime(const Consensus::Params ¶ms) const =0
virtual int Threshold(const Consensus::Params ¶ms) const =0
BIP9Stats GetStateStatisticsFor(const CBlockIndex *pindex, const Consensus::Params ¶ms, std::vector< bool > *signalling_blocks=nullptr) const
Returns the numerical statistics of an in-progress BIP9 softfork in the period including pindex If pr...
The block chain is a tree shaped structure starting with the genesis block at the root,...
BIP 9 allows multiple softforks to be deployed in parallel.
int StateSinceHeight(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Get the block height at which the BIP9 deployment switched into the state for the block after pindexP...
ThresholdConditionCache m_caches[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] GUARDED_BY(m_mutex)
static BIP9Stats Statistics(const CBlockIndex *pindex, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, std::vector< bool > *signalling_blocks=nullptr)
Get the numerical statistics for a given deployment for the signalling period that includes pindex.
int32_t ComputeBlockVersion(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Determine what nVersion a new block should use.
static uint32_t Mask(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
ThresholdState State(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.
void Clear() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
@ MAX_VERSION_BITS_DEPLOYMENTS
Display status of an in-progress BIP9 softfork.
int count
Number of blocks with the version bit set since the beginning of the current period.
int elapsed
Number of blocks elapsed since the beginning of the current period.
int threshold
Number of blocks with the version bit set required to activate the softfork.
bool possible
False if there are not enough blocks left in this period to pass activation threshold.
int period
Length of blocks of the BIP9 signalling period.
Parameters that influence chain consensus.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
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_LAST_OLD_BLOCK_VERSION
What block version to use for new blocks (pre versionbits)
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.