Skip to content

Commit 2b19f34

Browse files
committed
RPC/blockchain: getblockchaininfo: Include versionbits signalling details during LOCKED_IN
1 parent ee9befe commit 2b19f34

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 BIP9SoftForkDescPushBack(const CBlockIndex* active_chain_tip, UniVal
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 = VersionBitsStateSinceHeight(active_chain_tip, consensusParams, id, versionbitscache);
13871387
bip9.pushKV("since", since_height);
1388-
if (ThresholdState::STARTED == thresholdState)
1389-
{
1388+
if (has_signal) {
13901389
UniValue statsUV(UniValue::VOBJ);
13911390
BIP9Stats statsStruct = VersionBitsStatistics(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);
@@ -1439,18 +1440,18 @@ RPCHelpMan getblockchaininfo()
14391440
{RPCResult::Type::OBJ, "bip9", "status of bip9 softforks (only for \"bip9\" type)",
14401441
{
14411442
{RPCResult::Type::STR, "status", "one of \"defined\", \"started\", \"locked_in\", \"active\", \"failed\""},
1442-
{RPCResult::Type::NUM, "bit", "the bit (0-28) in the block version field used to signal this softfork (only for \"started\" status)"},
1443+
{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)"},
14431444
{RPCResult::Type::NUM_TIME, "start_time", "the minimum median time past of a block at which the bit gains its meaning"},
14441445
{RPCResult::Type::NUM_TIME, "timeout", "the median time past of a block at which the deployment is considered failed if not yet locked in"},
14451446
{RPCResult::Type::NUM, "since", "height of the first block to which the status applies"},
14461447
{RPCResult::Type::NUM, "min_activation_height", "minimum height of blocks for which the rules may be enforced"},
1447-
{RPCResult::Type::OBJ, "statistics", "numeric statistics about BIP9 signalling for a softfork (only for \"started\" status)",
1448+
{RPCResult::Type::OBJ, "statistics", "numeric statistics about signalling for a softfork (only for \"started\" and \"locked_in\" status)",
14481449
{
1449-
{RPCResult::Type::NUM, "period", "the length in blocks of the BIP9 signalling period"},
1450-
{RPCResult::Type::NUM, "threshold", "the number of blocks with the version bit set required to activate the feature"},
1450+
{RPCResult::Type::NUM, "period", "the length in blocks of the signalling period"},
1451+
{RPCResult::Type::NUM, "threshold", "the number of blocks with the version bit set required to activate the feature (only for \"started\" status)"},
14511452
{RPCResult::Type::NUM, "elapsed", "the number of blocks elapsed since the beginning of the current period"},
14521453
{RPCResult::Type::NUM, "count", "the number of blocks with the version bit set in the current period"},
1453-
{RPCResult::Type::BOOL, "possible", "returns false if there are not enough blocks left in this period to pass activation threshold"},
1454+
{RPCResult::Type::BOOL, "possible", "returns false if there are not enough blocks left in this period to pass activation threshold (only for \"started\" status)"},
14541455
}},
14551456
}},
14561457
{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)