Skip to content

Commit a273e3c

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#21934: RPC/blockchain: getblockchaininfo: Include versionbits signalling details during LOCKED_IN
2b19f34 RPC/blockchain: getblockchaininfo: Include versionbits signalling details during LOCKED_IN (Luke Dashjr) Pull request description: While the signal has no effect during `LOCKED_IN`, the bit is still defined and recommended for measuring uptake. Makes sense to expose statistics too. ACKs for top commit: prayank23: ACK bitcoin/bitcoin@2b19f34 Sjors: tACK 2b19f34 theStack: Tested ACK 2b19f34 MarcoFalke: review-only ACK 2b19f34 Tree-SHA512: a9bb5adb21992586119cbb5f87e5348eabcab11d5a3bf769b00b69e466589a669846e503f8384fa8927fd77da0c2d64a54f13a7a55a62980046d70f8255ddf47
2 parents 458d6ac + 2b19f34 commit a273e3c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/rpc/blockchain.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,23 +1377,24 @@ static void SoftForkDescPushBack(const CBlockIndex* active_chain_tip, UniValue&
13771377
case ThresholdState::ACTIVE: bip9.pushKV("status", "active"); break;
13781378
case ThresholdState::FAILED: bip9.pushKV("status", "failed"); break;
13791379
}
1380-
if (ThresholdState::STARTED == thresholdState)
1381-
{
1380+
const bool has_signal = (ThresholdState::STARTED == thresholdState || ThresholdState::LOCKED_IN == thresholdState);
1381+
if (has_signal) {
13821382
bip9.pushKV("bit", consensusParams.vDeployments[id].bit);
13831383
}
13841384
bip9.pushKV("start_time", consensusParams.vDeployments[id].nStartTime);
13851385
bip9.pushKV("timeout", consensusParams.vDeployments[id].nTimeout);
13861386
int64_t since_height = g_versionbitscache.StateSinceHeight(active_chain_tip, consensusParams, id);
13871387
bip9.pushKV("since", since_height);
1388-
if (ThresholdState::STARTED == thresholdState)
1389-
{
1388+
if (has_signal) {
13901389
UniValue statsUV(UniValue::VOBJ);
13911390
BIP9Stats statsStruct = g_versionbitscache.Statistics(active_chain_tip, consensusParams, id);
13921391
statsUV.pushKV("period", statsStruct.period);
1393-
statsUV.pushKV("threshold", statsStruct.threshold);
13941392
statsUV.pushKV("elapsed", statsStruct.elapsed);
13951393
statsUV.pushKV("count", statsStruct.count);
1396-
statsUV.pushKV("possible", statsStruct.possible);
1394+
if (ThresholdState::LOCKED_IN != thresholdState) {
1395+
statsUV.pushKV("threshold", statsStruct.threshold);
1396+
statsUV.pushKV("possible", statsStruct.possible);
1397+
}
13971398
bip9.pushKV("statistics", statsUV);
13981399
}
13991400
bip9.pushKV("min_activation_height", consensusParams.vDeployments[id].min_activation_height);
@@ -1440,18 +1441,18 @@ RPCHelpMan getblockchaininfo()
14401441
{RPCResult::Type::OBJ, "bip9", "status of bip9 softforks (only for \"bip9\" type)",
14411442
{
14421443
{RPCResult::Type::STR, "status", "one of \"defined\", \"started\", \"locked_in\", \"active\", \"failed\""},
1443-
{RPCResult::Type::NUM, "bit", "the bit (0-28) in the block version field used to signal this softfork (only for \"started\" status)"},
1444+
{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)"},
14441445
{RPCResult::Type::NUM_TIME, "start_time", "the minimum median time past of a block at which the bit gains its meaning"},
14451446
{RPCResult::Type::NUM_TIME, "timeout", "the median time past of a block at which the deployment is considered failed if not yet locked in"},
14461447
{RPCResult::Type::NUM, "since", "height of the first block to which the status applies"},
14471448
{RPCResult::Type::NUM, "min_activation_height", "minimum height of blocks for which the rules may be enforced"},
1448-
{RPCResult::Type::OBJ, "statistics", "numeric statistics about BIP9 signalling for a softfork (only for \"started\" status)",
1449+
{RPCResult::Type::OBJ, "statistics", "numeric statistics about signalling for a softfork (only for \"started\" and \"locked_in\" status)",
14491450
{
1450-
{RPCResult::Type::NUM, "period", "the length in blocks of the BIP9 signalling period"},
1451-
{RPCResult::Type::NUM, "threshold", "the number of blocks with the version bit set required to activate the feature"},
1451+
{RPCResult::Type::NUM, "period", "the length in blocks of the signalling period"},
1452+
{RPCResult::Type::NUM, "threshold", "the number of blocks with the version bit set required to activate the feature (only for \"started\" status)"},
14521453
{RPCResult::Type::NUM, "elapsed", "the number of blocks elapsed since the beginning of the current period"},
14531454
{RPCResult::Type::NUM, "count", "the number of blocks with the version bit set in the current period"},
1454-
{RPCResult::Type::BOOL, "possible", "returns false if there are not enough blocks left in this period to pass activation threshold"},
1455+
{RPCResult::Type::BOOL, "possible", "returns false if there are not enough blocks left in this period to pass activation threshold (only for \"started\" status)"},
14551456
}},
14561457
}},
14571458
{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)