Skip to content

Commit 409f833

Browse files
committed
RPC: Hide softfork if timeout is 0
1 parent 5cdc54b commit 409f833

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/rpc/blockchain.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,15 @@ static UniValue BIP9SoftForkDesc(const Consensus::Params& consensusParams, Conse
868868
return rv;
869869
}
870870

871+
void BIP9SoftForkDescPushBack(UniValue& bip9_softforks, const std::string &name, const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
872+
{
873+
// Deployments with timeout value of 0 are hidden.
874+
// A timeout value of 0 guarantees a softfork will never be activated.
875+
// This is used when softfork codes are merged without specifying the deployment schedule.
876+
if (consensusParams.vDeployments[id].nTimeout > 0)
877+
bip9_softforks.push_back(Pair(name, BIP9SoftForkDesc(consensusParams, id)));
878+
}
879+
871880
UniValue getblockchaininfo(const UniValue& params, bool fHelp)
872881
{
873882
if (fHelp || params.size() != 0)
@@ -901,7 +910,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
901910
" ],\n"
902911
" \"bip9_softforks\": { (object) status of BIP9 softforks in progress\n"
903912
" \"xxxx\" : { (string) name of the softfork\n"
904-
" \"status\": \"xxxx\", (string) one of \"defined\", \"started\", \"lockedin\", \"active\", \"failed\"\n"
913+
" \"status\": \"xxxx\", (string) one of \"defined\", \"started\", \"locked_in\", \"active\", \"failed\"\n"
905914
" \"bit\": xx, (numeric) the bit, 0-28, in the block version field used to signal this soft fork\n"
906915
" \"startTime\": xx, (numeric) the minimum median time past of a block at which the bit gains its meaning\n"
907916
" \"timeout\": xx (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in\n"
@@ -933,8 +942,8 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
933942
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
934943
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
935944
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
936-
bip9_softforks.push_back(Pair("csv", BIP9SoftForkDesc(consensusParams, Consensus::DEPLOYMENT_CSV)));
937-
bip9_softforks.push_back(Pair("segwit", BIP9SoftForkDesc(consensusParams, Consensus::DEPLOYMENT_SEGWIT)));
945+
BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV);
946+
BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT);
938947
obj.push_back(Pair("softforks", softforks));
939948
obj.push_back(Pair("bip9_softforks", bip9_softforks));
940949

0 commit comments

Comments
 (0)