6#include <chainparams.h>
47 std::vector<std::unique_ptr<CBlockIndex>> m_blocks;
55 : m_start_time{start_time}, m_interval{
interval}, m_signal{signal}, m_no_signal{
no_signal} {}
57 size_t size()
const {
return m_blocks.size(); }
61 return m_blocks.empty() ?
nullptr : m_blocks.back().get();
67 header.
nVersion = signal ? m_signal : m_no_signal;
68 header.
nTime = m_start_time + m_blocks.size() * m_interval;
69 header.
nBits = 0x1d00ffff;
80std::unique_ptr<const CChainParams>
g_params;
154 TestConditionChecker checker(dep);
184 for (
uint32_t b = 0; b < period; ++b) {
185 blocks.mine_block(signal);
215 for (
uint32_t b = 1; b < period; ++b) {
226 const int since = checker.GetStateSinceHeightFor(
current_block);
231 std::vector<bool> signals;
246 assert(signals.back() == signal);
271 const int since = checker.GetStateSinceHeightFor(
current_block);
274 assert(since % period == 0);
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const ChainType chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
ThresholdState GetStateFor(const CBlockIndex *pindexPrev, ThresholdConditionCache &cache) const
Returns the state for pindex A based on parent pindexPrev B.
int GetStateSinceHeightFor(const CBlockIndex *pindexPrev, ThresholdConditionCache &cache) const
Returns the height since when the ThresholdState has started for pindex A based on parent pindexPrev ...
The block chain is a tree shaped structure starting with the genesis block at the root,...
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const CBlock & GenesisBlock() const
const Consensus::Params & GetConsensus() const
T ConsumeIntegralInRange(T min, T max)
Class to implement versionbits logic.
Display status of an in-progress BIP9 softfork.
uint32_t count
Number of blocks with the version bit set since the beginning of the current period.
uint32_t threshold
Number of blocks with the version bit set required to activate the softfork.
uint32_t elapsed
Number of blocks elapsed since the beginning of the current period.
bool possible
False if there are not enough blocks left in this period to pass activation threshold.
uint32_t period
Length of blocks of the BIP9 signalling period.
Struct for each individual consensus rule change using BIP9.
int min_activation_height
If lock in occurs, delay activation until at least this block height.
int bit
Bit position to select the particular bit in nVersion.
static constexpr int64_t ALWAYS_ACTIVE
Special value for nStartTime indicating that the deployment is always active.
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
uint32_t period
Period of blocks to check signalling in (usually retarget period, ie params.DifficultyAdjustmentInter...
uint32_t threshold
Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,...
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
static constexpr int64_t NO_TIMEOUT
Constant for nTimeout very far in the future.
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
int64_t nPowTargetSpacing
constexpr int VERSIONBITS_MAX_NUM_BITS
Total possible bits available for versionbits per original BIP 9 specification.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
std::map< const CBlockIndex *, ThresholdState > ThresholdConditionCache
constexpr int32_t VERSIONBITS_LAST_OLD_BLOCK_VERSION
What block version to use for new blocks (pre versionbits)
ThresholdState
BIP 9 defines a finite-state-machine to deploy a softfork in multiple stages.
FuzzedDataProvider & fuzzed_data_provider