@@ -222,16 +222,23 @@ BIP9Info VersionBitsCache::Info(const CBlockIndex& block_index, const Consensus:
222
222
{
223
223
BIP9Info result;
224
224
225
- const auto current_state = State (block_index.pprev , params, id);
226
- result.current_state = StateName (current_state);
227
- result.since = StateSinceHeight (block_index.pprev , params, id);
225
+ VersionBitsConditionChecker checker (params, id);
226
+
227
+ ThresholdState current_state, next_state;
228
+
229
+ {
230
+ LOCK (m_mutex);
231
+ current_state = checker.GetStateFor (block_index.pprev , m_caches[id]);
232
+ next_state = checker.GetStateFor (&block_index, m_caches[id]);
233
+ result.since = checker.GetStateSinceHeightFor (block_index.pprev , m_caches[id]);
234
+ }
228
235
229
- const auto next_state = State (&block_index, params, id );
236
+ result. current_state = StateName (current_state );
230
237
result.next_state = StateName (next_state);
231
238
232
239
const bool has_signal = (STARTED == current_state || LOCKED_IN == current_state);
233
240
if (has_signal) {
234
- result.stats .emplace (Statistics (&block_index, params, id , &result.signalling_blocks ));
241
+ result.stats .emplace (checker. GetStateStatisticsFor (&block_index, &result.signalling_blocks ));
235
242
if (LOCKED_IN == current_state) {
236
243
result.stats ->threshold = 0 ;
237
244
result.stats ->possible = false ;
@@ -278,26 +285,10 @@ BIP9GBTStatus VersionBitsCache::GBTStatus(const CBlockIndex& block_index, const
278
285
return result;
279
286
}
280
287
281
- ThresholdState VersionBitsCache::State (const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos)
282
- {
283
- LOCK (m_mutex);
284
- return VersionBitsConditionChecker (params, pos).GetStateFor (pindexPrev, m_caches[pos]);
285
- }
286
-
287
- BIP9Stats VersionBitsCache::Statistics (const CBlockIndex* pindex, const Consensus::Params& params, Consensus::DeploymentPos pos, std::vector<bool >* signalling_blocks)
288
- {
289
- return VersionBitsConditionChecker (params, pos).GetStateStatisticsFor (pindex, signalling_blocks);
290
- }
291
-
292
- int VersionBitsCache::StateSinceHeight (const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos)
288
+ bool VersionBitsCache::IsActiveAfter (const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos)
293
289
{
294
290
LOCK (m_mutex);
295
- return VersionBitsConditionChecker (params, pos).GetStateSinceHeightFor (pindexPrev, m_caches[pos]);
296
- }
297
-
298
- uint32_t VersionBitsCache::Mask (const Consensus::Params& params, Consensus::DeploymentPos pos)
299
- {
300
- return VersionBitsConditionChecker (params, pos).Mask ();
291
+ return ThresholdState::ACTIVE == VersionBitsConditionChecker (params, pos).GetStateFor (pindexPrev, m_caches[pos]);
301
292
}
302
293
303
294
static int32_t ComputeBlockVersion (const CBlockIndex* pindexPrev, const Consensus::Params& params, std::array<ThresholdConditionCache, Consensus::MAX_VERSION_BITS_DEPLOYMENTS>& caches)
0 commit comments