Skip to content

Commit 9e38d35

Browse files
committed
Merge #10874: [RPC] getblockchaininfo: Loop through the bip9 soft fork deployments instead of hard coding
e4d0af4 Loop through the bip9 soft fork deployments instead of hard coding (Andrew Chow) Pull request description: Instead of hard coding which deployment statistics should be listed in the `getblockchaininfo` output, loop through the available deployments (except testdummy) when displaying their deployment info. Tree-SHA512: 87e503bcf5e0fd379940d5e53320b9cbb4b47d647c66246d46f47c09a941f135e6ce1e8b75dad441ed4c22c3f41992dfde7717414be1d71c771d4ff8fe0e1936
2 parents 60d739e + e4d0af4 commit 9e38d35

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/rpc/blockchain.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,13 +1113,13 @@ static UniValue BIP9SoftForkDesc(const Consensus::Params& consensusParams, Conse
11131113
return rv;
11141114
}
11151115

1116-
void BIP9SoftForkDescPushBack(UniValue& bip9_softforks, const std::string &name, const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
1116+
void BIP9SoftForkDescPushBack(UniValue& bip9_softforks, const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
11171117
{
11181118
// Deployments with timeout value of 0 are hidden.
11191119
// A timeout value of 0 guarantees a softfork will never be activated.
11201120
// This is used when softfork codes are merged without specifying the deployment schedule.
11211121
if (consensusParams.vDeployments[id].nTimeout > 0)
1122-
bip9_softforks.push_back(Pair(name, BIP9SoftForkDesc(consensusParams, id)));
1122+
bip9_softforks.push_back(Pair(VersionBitsDeploymentInfo[id].name, BIP9SoftForkDesc(consensusParams, id)));
11231123
}
11241124

11251125
UniValue getblockchaininfo(const JSONRPCRequest& request)
@@ -1214,8 +1214,9 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
12141214
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
12151215
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
12161216
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
1217-
BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV);
1218-
BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT);
1217+
for (int pos = Consensus::DEPLOYMENT_CSV; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) {
1218+
BIP9SoftForkDescPushBack(bip9_softforks, consensusParams, static_cast<Consensus::DeploymentPos>(pos));
1219+
}
12191220
obj.push_back(Pair("softforks", softforks));
12201221
obj.push_back(Pair("bip9_softforks", bip9_softforks));
12211222

0 commit comments

Comments
 (0)