File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ struct BIP9Deployment {
35
35
36
36
/* * Constant for nTimeout very far in the future. */
37
37
static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t >::max();
38
+
39
+ /* * Special value for nStartTime indicating that the deployment is always active.
40
+ * This is useful for testing, as it means tests don't need to deal with the activation
41
+ * process (which takes at least 3 BIP9 intervals). Only tests that specifically test the
42
+ * behaviour during activation cannot use this. */
43
+ static constexpr int64_t ALWAYS_ACTIVE = -1 ;
38
44
};
39
45
40
46
/* *
Original file line number Diff line number Diff line change @@ -27,6 +27,11 @@ ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex*
27
27
int64_t nTimeStart = BeginTime (params);
28
28
int64_t nTimeTimeout = EndTime (params);
29
29
30
+ // Check if this deployment is always active.
31
+ if (nTimeStart == Consensus::BIP9Deployment::ALWAYS_ACTIVE) {
32
+ return THRESHOLD_ACTIVE;
33
+ }
34
+
30
35
// 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.
31
36
if (pindexPrev != nullptr ) {
32
37
pindexPrev = pindexPrev->GetAncestor (pindexPrev->nHeight - ((pindexPrev->nHeight + 1 ) % nPeriod));
@@ -136,6 +141,11 @@ BIP9Stats AbstractThresholdConditionChecker::GetStateStatisticsFor(const CBlockI
136
141
137
142
int AbstractThresholdConditionChecker::GetStateSinceHeightFor (const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const
138
143
{
144
+ int64_t start_time = BeginTime (params);
145
+ if (start_time == Consensus::BIP9Deployment::ALWAYS_ACTIVE) {
146
+ return 0 ;
147
+ }
148
+
139
149
const ThresholdState initialState = GetStateFor (pindexPrev, params, cache);
140
150
141
151
// BIP 9 about state DEFINED: "The genesis block is by definition in this state for each deployment."
You can’t perform that action at this time.
0 commit comments