mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 23:58:18 +00:00
Always-active versionbits support
This commit is contained in:
parent
18e071841e
commit
d07ee77ab9
@ -35,6 +35,12 @@ struct BIP9Deployment {
|
|||||||
|
|
||||||
/** Constant for nTimeout very far in the future. */
|
/** Constant for nTimeout very far in the future. */
|
||||||
static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max();
|
static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max();
|
||||||
|
|
||||||
|
/** Special value for nStartTime indicating that the deployment is always active.
|
||||||
|
* This is useful for testing, as it means tests don't need to deal with the activation
|
||||||
|
* process (which takes at least 3 BIP9 intervals). Only tests that specifically test the
|
||||||
|
* behaviour during activation cannot use this. */
|
||||||
|
static constexpr int64_t ALWAYS_ACTIVE = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +27,11 @@ ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex*
|
|||||||
int64_t nTimeStart = BeginTime(params);
|
int64_t nTimeStart = BeginTime(params);
|
||||||
int64_t nTimeTimeout = EndTime(params);
|
int64_t nTimeTimeout = EndTime(params);
|
||||||
|
|
||||||
|
// Check if this deployment is always active.
|
||||||
|
if (nTimeStart == Consensus::BIP9Deployment::ALWAYS_ACTIVE) {
|
||||||
|
return THRESHOLD_ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
// A block's state is always the same as that of the first of its period, so it is computed based on a pindexPrev whose height equals a multiple of nPeriod - 1.
|
// A block's state is always the same as that of the first of its period, so it is computed based on a pindexPrev whose height equals a multiple of nPeriod - 1.
|
||||||
if (pindexPrev != nullptr) {
|
if (pindexPrev != nullptr) {
|
||||||
pindexPrev = pindexPrev->GetAncestor(pindexPrev->nHeight - ((pindexPrev->nHeight + 1) % nPeriod));
|
pindexPrev = pindexPrev->GetAncestor(pindexPrev->nHeight - ((pindexPrev->nHeight + 1) % nPeriod));
|
||||||
@ -136,6 +141,11 @@ BIP9Stats AbstractThresholdConditionChecker::GetStateStatisticsFor(const CBlockI
|
|||||||
|
|
||||||
int AbstractThresholdConditionChecker::GetStateSinceHeightFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const
|
int AbstractThresholdConditionChecker::GetStateSinceHeightFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const
|
||||||
{
|
{
|
||||||
|
int64_t start_time = BeginTime(params);
|
||||||
|
if (start_time == Consensus::BIP9Deployment::ALWAYS_ACTIVE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const ThresholdState initialState = GetStateFor(pindexPrev, params, cache);
|
const ThresholdState initialState = GetStateFor(pindexPrev, params, cache);
|
||||||
|
|
||||||
// BIP 9 about state DEFINED: "The genesis block is by definition in this state for each deployment."
|
// BIP 9 about state DEFINED: "The genesis block is by definition in this state for each deployment."
|
||||||
|
Loading…
Reference in New Issue
Block a user