Skip to content

Commit 07e4c2c

Browse files
committed
merge bitcoin#21934: Include versionbits signalling details during LOCKED_IN
1 parent 960e768 commit 07e4c2c

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/rpc/blockchain.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,8 +1650,8 @@ static void SoftForkDescPushBack(const CBlockIndex* active_chain_tip, const std:
16501650
case ThresholdState::ACTIVE: bip9.pushKV("status", "active"); break;
16511651
case ThresholdState::FAILED: bip9.pushKV("status", "failed"); break;
16521652
}
1653-
if (ThresholdState::STARTED == thresholdState)
1654-
{
1653+
const bool has_signal = (ThresholdState::STARTED == thresholdState || ThresholdState::LOCKED_IN == thresholdState);
1654+
if (has_signal) {
16551655
bip9.pushKV("bit", consensusParams.vDeployments[id].bit);
16561656
}
16571657
bip9.pushKV("start_time", consensusParams.vDeployments[id].nStartTime);
@@ -1662,18 +1662,19 @@ static void SoftForkDescPushBack(const CBlockIndex* active_chain_tip, const std:
16621662
}
16631663
int64_t since_height = g_versionbitscache.StateSinceHeight(active_chain_tip, consensusParams, id);
16641664
bip9.pushKV("since", since_height);
1665-
if (ThresholdState::STARTED == thresholdState)
1666-
{
1665+
if (has_signal) {
16671666
UniValue statsUV(UniValue::VOBJ);
16681667
BIP9Stats statsStruct = g_versionbitscache.Statistics(active_chain_tip, consensusParams, id);
16691668
statsUV.pushKV("period", statsStruct.period);
1670-
statsUV.pushKV("threshold", statsStruct.threshold);
16711669
statsUV.pushKV("elapsed", statsStruct.elapsed);
16721670
statsUV.pushKV("count", statsStruct.count);
1673-
statsUV.pushKV("possible", statsStruct.possible);
1671+
if (ThresholdState::LOCKED_IN != thresholdState) {
1672+
statsUV.pushKV("threshold", statsStruct.threshold);
1673+
statsUV.pushKV("possible", statsStruct.possible);
1674+
}
16741675
bip9.pushKV("statistics", statsUV);
16751676
}
1676-
else if (ThresholdState::LOCKED_IN == thresholdState) {
1677+
if (ThresholdState::LOCKED_IN == thresholdState) {
16771678
bip9.pushKV("activation_height", since_height + static_cast<int>(consensusParams.vDeployments[id].nWindowSize));
16781679
}
16791680
bip9.pushKV("min_activation_height", consensusParams.vDeployments[id].min_activation_height);
@@ -1719,21 +1720,21 @@ RPCHelpMan getblockchaininfo()
17191720
{RPCResult::Type::OBJ, "bip9", "status of bip9 softforks (only for \"bip9\" type)",
17201721
{
17211722
{RPCResult::Type::STR, "status", "one of \"defined\", \"started\", \"locked_in\", \"active\", \"failed\""},
1722-
{RPCResult::Type::NUM, "bit", "the bit (0-28) in the block version field used to signal this softfork (only for \"started\" status)"},
1723+
{RPCResult::Type::NUM, "bit", "the bit (0-28) in the block version field used to signal this softfork (only for \"started\" and \"locked_in\" status)"},
17231724
{RPCResult::Type::NUM_TIME, "start_time", "the minimum median time past of a block at which the bit gains its meaning"},
17241725
{RPCResult::Type::NUM_TIME, "timeout", "the median time past of a block at which the deployment is considered failed if not yet locked in"},
17251726
{RPCResult::Type::BOOL, "ehf", "returns true for EHF activated forks"},
17261727
{RPCResult::Type::NUM, "ehf_height", /* optional */ true, "the minimum height when miner's signals for the deployment matter. Below this height miner signaling cannot trigger hard fork lock-in. Not specified for non-EHF forks"},
17271728
{RPCResult::Type::NUM, "since", "height of the first block to which the status applies"},
17281729
{RPCResult::Type::NUM, "activation_height", "expected activation height for this softfork (only for \"locked_in\" status)"},
17291730
{RPCResult::Type::NUM, "min_activation_height", "minimum height of blocks for which the rules may be enforced"},
1730-
{RPCResult::Type::OBJ, "statistics", "numeric statistics about BIP9 signalling for a softfork (only for \"started\" status)",
1731+
{RPCResult::Type::OBJ, "statistics", "numeric statistics about signalling for a softfork (only for \"started\" and \"locked_in\" status)",
17311732
{
1732-
{RPCResult::Type::NUM, "period", "the length in blocks of the BIP9 signalling period"},
1733-
{RPCResult::Type::NUM, "threshold", "the number of blocks with the version bit set required to activate the feature"},
1733+
{RPCResult::Type::NUM, "period", "the length in blocks of the signalling period"},
1734+
{RPCResult::Type::NUM, "threshold", "the number of blocks with the version bit set required to activate the feature (only for \"started\" status)"},
17341735
{RPCResult::Type::NUM, "elapsed", "the number of blocks elapsed since the beginning of the current period"},
17351736
{RPCResult::Type::NUM, "count", "the number of blocks with the version bit set in the current period"},
1736-
{RPCResult::Type::BOOL, "possible", "returns false if there are not enough blocks left in this period to pass activation threshold"},
1737+
{RPCResult::Type::BOOL, "possible", "returns false if there are not enough blocks left in this period to pass activation threshold (only for \"started\" status)"},
17371738
}},
17381739
}},
17391740
{RPCResult::Type::NUM, "height", "height of the first block which the rules are or will be enforced (only for \"buried\" type, or \"bip9\" type with \"active\" status)"},

0 commit comments

Comments
 (0)