 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
10 int nPeriod =
Period(params);
14 int64_t nTimeTimeout =
EndTime(params);
27 if (pindexPrev !=
nullptr) {
32 std::vector<const CBlockIndex*> vToCompute;
33 while (cache.count(pindexPrev) == 0) {
34 if (pindexPrev ==
nullptr) {
44 vToCompute.push_back(pindexPrev);
49 assert(cache.count(pindexPrev));
53 while (!vToCompute.empty()) {
55 pindexPrev = vToCompute.back();
56 vToCompute.pop_back();
69 for (
int i = 0; i < nPeriod; i++) {
73 pindexCount = pindexCount->
pprev;
75 if (
count >= nThreshold) {
84 if (pindexPrev->
nHeight + 1 >= min_activation_height) {
95 cache[pindexPrev] = state = stateNext;
108 if (pindex ==
nullptr)
return stats;
114 if (signalling_blocks) {
115 signalling_blocks->assign(blocks_in_period,
false);
127 if (signalling_blocks) signalling_blocks->at(blocks_in_period) =
true;
129 currentIndex = currentIndex->
pprev;
130 }
while(blocks_in_period > 0);
153 const int nPeriod =
Period(params);
165 while (previousPeriodParent !=
nullptr &&
GetStateFor(previousPeriodParent, params, cache) == initialState) {
166 pindexPrev = previousPeriodParent;
171 return pindexPrev->
nHeight + 1;
205 return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, m_caches[pos]);
210 return VersionBitsConditionChecker(pos).GetStateStatisticsFor(pindex, params, signalling_blocks);
216 return VersionBitsConditionChecker(pos).GetStateSinceHeightFor(pindexPrev, params, m_caches[pos]);
221 return VersionBitsConditionChecker(pos).Mask(params);
231 ThresholdState state = VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, m_caches[pos]);
233 nVersion |=
Mask(params, pos);
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
static const int32_t VERSIONBITS_TOP_MASK
What bitmask determines whether versionbits is in use.
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
ThresholdState State(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
Get the BIP9 state for a given deployment for the block after pindexPrev.
int bit
Bit position to select the particular bit in nVersion.
int32_t ComputeBlockVersion(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms)
Determine what nVersion a new block should use.
@ MAX_VERSION_BITS_DEPLOYMENTS
virtual int Threshold(const Consensus::Params ¶ms) const =0
CBlockIndex * pprev
pointer to the index of the predecessor of this block
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
virtual int64_t EndTime(const Consensus::Params ¶ms) const =0
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
Returns the state for pindex A based on parent pindexPrev B.
uint32_t nMinerConfirmationWindow
static const int32_t VERSIONBITS_TOP_BITS
What bits to set in version for versionbits blocks.
uint32_t nRuleChangeActivationThreshold
Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,...
std::map< const CBlockIndex *, ThresholdState > ThresholdConditionCache
virtual int Period(const Consensus::Params ¶ms) const =0
BIP9Stats GetStateStatisticsFor(const CBlockIndex *pindex, const Consensus::Params ¶ms, std::vector< bool > *signalling_blocks=nullptr) const
Returns the numerical statistics of an in-progress BIP9 softfork in the period including pindex If pr...
Parameters that influence chain consensus.
constexpr I Mask()
Return a value of type I with its bits lowest bits set (bits must be > 0).
static BIP9Stats Statistics(const CBlockIndex *pindex, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, std::vector< bool > *signalling_blocks=nullptr)
Get the numerical statistics for a given deployment for the signalling period that includes pindex.
int GetStateSinceHeightFor(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, ThresholdConditionCache &cache) const
Returns the height since when the ThresholdState has started for pindex A based on parent pindexPrev ...
int64_t GetMedianTimePast() const
virtual int64_t BeginTime(const Consensus::Params ¶ms) const =0
int32_t nVersion
block header
static uint32_t Mask(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
int count
Number of blocks with the version bit set since the beginning of the current period.
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
int threshold
Number of blocks with the version bit set required to activate the softfork.
Abstract class that implements BIP9-style threshold logic, and caches results.
virtual int MinActivationHeight(const Consensus::Params ¶ms) const
int min_activation_height
If lock in occurs, delay activation until at least this block height.
Display status of an in-progress BIP9 softfork.
int StateSinceHeight(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
Get the block height at which the BIP9 deployment switched into the state for the block after pindexP...
virtual bool Condition(const CBlockIndex *pindex, const Consensus::Params ¶ms) const =0
int elapsed
Number of blocks elapsed since the beginning of the current period.
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
bool possible
False if there are not enough blocks left in this period to pass activation threshold.
int period
Length of blocks of the BIP9 signalling period.
ThresholdState
BIP 9 defines a finite-state-machine to deploy a softfork in multiple stages.
The block chain is a tree shaped structure starting with the genesis block at the root,...
static constexpr int64_t ALWAYS_ACTIVE
Special value for nStartTime indicating that the deployment is always active.