34 int nPeriod = Period(params);
35 int nThreshold = Threshold(params);
36 int64_t nTimeStart = BeginTime(params);
37 int64_t nTimeTimeout = EndTime(params);
40 if (pindexPrev !=
nullptr) {
45 std::vector<const CBlockIndex*> vToCompute;
46 while (cache.count(pindexPrev) == 0) {
47 if (pindexPrev ==
nullptr) {
57 vToCompute.push_back(pindexPrev);
62 assert(cache.count(pindexPrev));
66 while (!vToCompute.empty()) {
68 pindexPrev = vToCompute.back();
69 vToCompute.pop_back();
88 for (
int i = 0; i < nPeriod; i++) {
89 if (Condition(pindexCount, params)) {
92 pindexCount = pindexCount->
pprev;
94 if (count >= nThreshold) {
110 cache[pindexPrev] = state = stateNext;
121 stats.
period = Period(params);
124 if (pindex ==
nullptr)
135 if (Condition(currentIndex, params))
137 currentIndex = currentIndex->
pprev;
148 const ThresholdState initialState = GetStateFor(pindexPrev, params, cache);
155 const int nPeriod = Period(params);
167 while (previousPeriodParent !=
nullptr && GetStateFor(previousPeriodParent, params, cache) == initialState) {
168 pindexPrev = previousPeriodParent;
173 return pindexPrev->
nHeight + 1;
201 return ((pindex->
nVersion & Mask(params)) != 0);
213 return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, cache.
caches[pos]);
218 return VersionBitsConditionChecker(pos).GetStateStatisticsFor(pindexPrev, params);
223 return VersionBitsConditionChecker(pos).GetStateSinceHeightFor(pindexPrev, params, cache.
caches[pos]);
228 return VersionBitsConditionChecker(pos).Mask(params);
uint32_t nOverrideMinerConfirmationWindow
Use to override the confirmation window on a specific BIP.
CBlockIndex * pprev
pointer to the index of the predecessor of this block
int GetStateSinceHeightFor(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]
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
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...
uint32_t nRuleChangeActivationThreshold
Block height at which BIP65 becomes active.
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)
uint32_t nOverrideRuleChangeActivationThreshold
Use to override the the activation threshold on a specific BIP.
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]