25 int nPeriod = Period(params);
26 int nThreshold = Threshold(params);
27 int64_t nTimeStart = BeginTime(params);
28 int64_t nTimeTimeout = EndTime(params);
31 if (pindexPrev !=
nullptr) {
36 std::vector<const CBlockIndex*> vToCompute;
37 while (cache.count(pindexPrev) == 0) {
38 if (pindexPrev ==
nullptr) {
48 vToCompute.push_back(pindexPrev);
53 assert(cache.count(pindexPrev));
57 while (!vToCompute.empty()) {
59 pindexPrev = vToCompute.back();
60 vToCompute.pop_back();
79 for (
int i = 0; i < nPeriod; i++) {
80 if (Condition(pindexCount, params)) {
83 pindexCount = pindexCount->
pprev;
85 if (count >= nThreshold) {
101 cache[pindexPrev] = state = stateNext;
112 stats.
period = Period(params);
115 if (pindex ==
nullptr)
126 if (Condition(currentIndex, params))
128 currentIndex = currentIndex->
pprev;
139 const ThresholdState initialState = GetStateFor(pindexPrev, params, cache);
146 const int nPeriod = Period(params);
158 while (previousPeriodParent !=
nullptr && GetStateFor(previousPeriodParent, params, cache) == initialState) {
159 pindexPrev = previousPeriodParent;
164 return pindexPrev->
nHeight + 1;
184 return (((pindex->
nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->
nVersion & Mask(params)) != 0);
196 return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, cache.
caches[pos]);
201 return VersionBitsConditionChecker(pos).GetStateStatisticsFor(pindexPrev, params);
206 return VersionBitsConditionChecker(pos).GetStateSinceHeightFor(pindexPrev, params, cache.
caches[pos]);
211 return VersionBitsConditionChecker(pos).Mask(params);
CBlockIndex * pprev
pointer to the index of the predecessor of this block
ThresholdState GetStateFor(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, ThresholdConditionCache &cache) const
const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
ThresholdConditionCache caches[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
assert(len-trim+(2 *lenIndices)<=WIDTH)
uint32_t VersionBitsMask(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
int GetStateSinceHeightFor(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, ThresholdConditionCache &cache) const
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.
BIP9Stats GetStateStatisticsFor(const CBlockIndex *pindex, const Consensus::Params ¶ms) const
uint32_t nMinerConfirmationWindow
Parameters that influence chain consensus.
std::map< const CBlockIndex *, ThresholdState > ThresholdConditionCache
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
The block chain is a tree shaped structure starting with the genesis block at the root...
uint32_t nRuleChangeActivationThreshold
Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period...
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)
int64_t GetMedianTimePast() const
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]