29 int nPeriod =
Period(params);
32 int64_t nTimeTimeout =
EndTime(params);
35 if (pindexPrev != NULL) {
40 std::vector<const CBlockIndex*> vToCompute;
41 while (cache.count(pindexPrev) == 0) {
42 if (pindexPrev == NULL) {
52 vToCompute.push_back(pindexPrev);
57 assert(cache.count(pindexPrev));
61 while (!vToCompute.empty()) {
63 pindexPrev = vToCompute.back();
64 vToCompute.pop_back();
83 for (
int i = 0; i < nPeriod; i++) {
87 pindexCount = pindexCount->
pprev;
89 if (
count >= nThreshold) {
105 cache[pindexPrev] = state = stateNext;
140 return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, cache.
caches[pos]);
145 return VersionBitsConditionChecker(pos).Mask(params);
virtual bool Condition(const CBlockIndex *pindex, const Consensus::Params ¶ms) const =0
virtual int Period(const Consensus::Params ¶ms) const =0
static const int32_t VERSIONBITS_TOP_MASK
virtual int64_t BeginTime(const Consensus::Params ¶ms) const =0
ThresholdConditionCache caches[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
uint32_t VersionBitsMask(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
uint32_t nRuleChangeActivationThreshold
uint32_t nMinerConfirmationWindow
virtual int Threshold(const Consensus::Params ¶ms) const =0
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
std::map< const CBlockIndex *, ThresholdState > ThresholdConditionCache
static const int32_t VERSIONBITS_TOP_BITS
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
int64_t GetMedianTimePast() const
CBlockIndex * pprev
pointer to the index of the predecessor of this block
ThresholdState VersionBitsState(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, VersionBitsCache &cache)
int nHeight
height of the entry in the chain. The genesis block has height 0
ThresholdState GetStateFor(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, ThresholdConditionCache &cache) const
const struct BIP9DeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
virtual int64_t EndTime(const Consensus::Params ¶ms) const =0