Skip to content

Commit e4d0af4

Browse files
committed
Loop through the bip9 soft fork deployments instead of hard coding
1 parent 9e8d6a3 commit e4d0af4

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
@@ -1107,13 +1107,13 @@ static UniValue BIP9SoftForkDesc(const Consensus::Params& consensusParams, Conse
11071107
return rv;
11081108
}
11091109

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

11191119
UniValue getblockchaininfo(const JSONRPCRequest& request)
@@ -1185,8 +1185,9 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
11851185
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
11861186
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
11871187
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
1188-
BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV);
1189-
BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT);
1188+
for (int pos = Consensus::DEPLOYMENT_CSV; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) {
1189+
BIP9SoftForkDescPushBack(bip9_softforks, consensusParams, static_cast<Consensus::DeploymentPos>(pos));
1190+
}
11901191
obj.push_back(Pair("softforks", softforks));
11911192
obj.push_back(Pair("bip9_softforks", bip9_softforks));
11921193

0 commit comments

Comments
 (0)