10 int nPeriod =
Period(params);
13 int64_t nTimeTimeout =
EndTime(params);
16 if (pindexPrev !=
nullptr) {
21 std::vector<const CBlockIndex*> vToCompute;
22 while (cache.count(pindexPrev) == 0) {
23 if (pindexPrev ==
nullptr) {
33 vToCompute.push_back(pindexPrev);
38 assert(cache.count(pindexPrev));
42 while (!vToCompute.empty()) {
44 pindexPrev = vToCompute.back();
45 vToCompute.pop_back();
64 for (
int i = 0; i < nPeriod; i++) {
68 pindexCount = pindexCount->
pprev;
70 if (count >= nThreshold) {
86 cache[pindexPrev] = state = stateNext;
100 if (pindex ==
nullptr)
113 currentIndex = currentIndex->
pprev;
132 const int nPeriod =
Period(params);
144 while (previousPeriodParent !=
nullptr &&
GetStateFor(previousPeriodParent, params, cache) == initialState) {
145 pindexPrev = previousPeriodParent;
150 return pindexPrev->
nHeight + 1;
170 return (((pindex->
nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->
nVersion & Mask(params)) != 0);
182 return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, cache.
caches[pos]);
187 return VersionBitsConditionChecker(pos).GetStateStatisticsFor(pindexPrev, params);
192 return VersionBitsConditionChecker(pos).GetStateSinceHeightFor(pindexPrev, params, cache.
caches[pos]);
197 return VersionBitsConditionChecker(pos).Mask(params);
CBlockIndex * pprev
pointer to the index of the predecessor of this block
virtual int64_t EndTime(const Consensus::Params ¶ms) const =0
int GetStateSinceHeightFor(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, ThresholdConditionCache &cache) const
virtual bool Condition(const CBlockIndex *pindex, const Consensus::Params ¶ms) const =0
ThresholdConditionCache caches[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
uint32_t VersionBitsMask(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
int VersionBitsStateSinceHeight(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, VersionBitsCache &cache)
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
Abstract class that implements BIP9-style threshold logic, and caches results.
uint32_t nMinerConfirmationWindow
Parameters that influence chain consensus.
int64_t GetMedianTimePast() const
virtual int Threshold(const Consensus::Params ¶ms) const =0
std::map< const CBlockIndex *, ThresholdState > ThresholdConditionCache
int32_t nVersion
block header
BIP9Stats GetStateStatisticsFor(const CBlockIndex *pindex, const Consensus::Params ¶ms) const
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
ThresholdState GetStateFor(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, ThresholdConditionCache &cache) const
The block chain is a tree shaped structure starting with the genesis block at the root...
virtual int64_t BeginTime(const Consensus::Params ¶ms) const =0
uint32_t nRuleChangeActivationThreshold
Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period...
virtual int Period(const Consensus::Params ¶ms) const =0
int nHeight
height of the entry in the chain. The genesis block has height 0
int bit
Bit position to select the particular bit in nVersion.
BIP9Stats VersionBitsStatistics(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
ThresholdState VersionBitsState(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, VersionBitsCache &cache)
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]