mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 14:14:00 +01:00
rpc: getdeploymentinfo: include signalling info
This commit is contained in:
@@ -98,7 +98,7 @@ ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex*
|
||||
return state;
|
||||
}
|
||||
|
||||
BIP9Stats AbstractThresholdConditionChecker::GetStateStatisticsFor(const CBlockIndex* pindex, const Consensus::Params& params) const
|
||||
BIP9Stats AbstractThresholdConditionChecker::GetStateStatisticsFor(const CBlockIndex* pindex, const Consensus::Params& params, std::vector<bool>* signalling_blocks) const
|
||||
{
|
||||
BIP9Stats stats = {};
|
||||
|
||||
@@ -108,18 +108,26 @@ BIP9Stats AbstractThresholdConditionChecker::GetStateStatisticsFor(const CBlockI
|
||||
if (pindex == nullptr) return stats;
|
||||
|
||||
// Find beginning of period
|
||||
int start_height = pindex->nHeight - (pindex->nHeight % stats.period);
|
||||
int blocks_in_period = 1 + (pindex->nHeight % stats.period);
|
||||
|
||||
// Reset signalling_blocks
|
||||
if (signalling_blocks) {
|
||||
signalling_blocks->assign(blocks_in_period, false);
|
||||
}
|
||||
|
||||
// Count from current block to beginning of period
|
||||
int elapsed = 0;
|
||||
int count = 0;
|
||||
const CBlockIndex* currentIndex = pindex;
|
||||
for(;;) {
|
||||
do {
|
||||
++elapsed;
|
||||
if (Condition(currentIndex, params)) ++count;
|
||||
if (currentIndex->nHeight <= start_height) break;
|
||||
--blocks_in_period;
|
||||
if (Condition(currentIndex, params)) {
|
||||
++count;
|
||||
if (signalling_blocks) signalling_blocks->at(blocks_in_period) = true;
|
||||
}
|
||||
currentIndex = currentIndex->pprev;
|
||||
}
|
||||
} while(blocks_in_period > 0);
|
||||
|
||||
stats.elapsed = elapsed;
|
||||
stats.count = count;
|
||||
@@ -197,9 +205,9 @@ ThresholdState VersionBitsCache::State(const CBlockIndex* pindexPrev, const Cons
|
||||
return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, m_caches[pos]);
|
||||
}
|
||||
|
||||
BIP9Stats VersionBitsCache::Statistics(const CBlockIndex* pindex, const Consensus::Params& params, Consensus::DeploymentPos pos)
|
||||
BIP9Stats VersionBitsCache::Statistics(const CBlockIndex* pindex, const Consensus::Params& params, Consensus::DeploymentPos pos, std::vector<bool>* signalling_blocks)
|
||||
{
|
||||
return VersionBitsConditionChecker(pos).GetStateStatisticsFor(pindex, params);
|
||||
return VersionBitsConditionChecker(pos).GetStateStatisticsFor(pindex, params, signalling_blocks);
|
||||
}
|
||||
|
||||
int VersionBitsCache::StateSinceHeight(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos)
|
||||
|
||||
Reference in New Issue
Block a user