26 int nPeriod =
Period(params);
29 int64_t nTimeTimeout =
EndTime(params);
32 if (pindexPrev != NULL) {
37 std::vector<const CBlockIndex*> vToCompute;
38 while (cache.count(pindexPrev) == 0) {
39 if (pindexPrev == NULL) {
49 vToCompute.push_back(pindexPrev);
54 assert(cache.count(pindexPrev));
58 while (!vToCompute.empty()) {
60 pindexPrev = vToCompute.back();
61 vToCompute.pop_back();
80 for (
int i = 0; i < nPeriod; i++) {
84 pindexCount = pindexCount->
pprev;
86 if (count >= nThreshold) {
102 cache[pindexPrev] = state = stateNext;
117 const int nPeriod =
Period(params);
129 while (previousPeriodParent != NULL &&
GetStateFor(previousPeriodParent, params, cache) == initialState) {
130 pindexPrev = previousPeriodParent;
135 return pindexPrev->
nHeight + 1;
155 return (((pindex->
nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->
nVersion & Mask(params)) != 0);
167 return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, cache.
caches[pos]);
172 return VersionBitsConditionChecker(pos).GetStateSinceHeightFor(pindexPrev, params, cache.
caches[pos]);
177 return VersionBitsConditionChecker(pos).Mask(params);
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
virtual int64_t EndTime(const Consensus::Params ¶ms) const =0
int GetStateSinceHeightFor(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, ThresholdConditionCache &cache) const
virtual int64_t BeginTime(const Consensus::Params ¶ms) const =0
virtual int Threshold(const Consensus::Params ¶ms) 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
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
@ MAX_VERSION_BITS_DEPLOYMENTS
int bit
Bit position to select the particular bit in nVersion.
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
Parameters that influence chain consensus.
uint32_t nMinerConfirmationWindow
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
uint32_t nRuleChangeActivationThreshold
Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,...
ThresholdConditionCache caches[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
uint32_t VersionBitsMask(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
const struct BIP9DeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
int VersionBitsStateSinceHeight(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, VersionBitsCache &cache)
ThresholdState VersionBitsState(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, VersionBitsCache &cache)
std::map< const CBlockIndex *, ThresholdState > ThresholdConditionCache