Add upgrades field to RPC call getblockchaininfo
Closes #2785. Co-authored-by: Jack Grigg <jack@z.cash>
This commit is contained in:
parent
d4d2844829
commit
71768555dd
|
@ -659,6 +659,37 @@ static UniValue SoftForkDesc(const std::string &name, int version, CBlockIndex*
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static UniValue NetworkUpgradeDesc(const Consensus::Params& consensusParams, Consensus::UpgradeIndex idx, int height)
|
||||||
|
{
|
||||||
|
UniValue rv(UniValue::VOBJ);
|
||||||
|
auto upgrade = NetworkUpgradeInfo[idx];
|
||||||
|
rv.push_back(Pair("name", upgrade.strName));
|
||||||
|
rv.push_back(Pair("activationheight", consensusParams.vUpgrades[idx].nActivationHeight));
|
||||||
|
switch (NetworkUpgradeState(height, consensusParams, idx)) {
|
||||||
|
case UPGRADE_DISABLED: rv.push_back(Pair("status", "disabled")); break;
|
||||||
|
case UPGRADE_PENDING: rv.push_back(Pair("status", "pending")); break;
|
||||||
|
case UPGRADE_ACTIVE: rv.push_back(Pair("status", "active")); break;
|
||||||
|
}
|
||||||
|
rv.push_back(Pair("info", upgrade.strInfo));
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkUpgradeDescPushBack(
|
||||||
|
UniValue& networkUpgrades,
|
||||||
|
const Consensus::Params& consensusParams,
|
||||||
|
Consensus::UpgradeIndex idx,
|
||||||
|
int height)
|
||||||
|
{
|
||||||
|
// Network upgrades with an activation height of NO_ACTIVATION_HEIGHT are
|
||||||
|
// hidden. This is used when network upgrade implementations are merged
|
||||||
|
// without specifying the activation height.
|
||||||
|
if (consensusParams.vUpgrades[idx].nActivationHeight != Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT) {
|
||||||
|
networkUpgrades.push_back(Pair(
|
||||||
|
HexInt(NetworkUpgradeInfo[idx].nBranchId),
|
||||||
|
NetworkUpgradeDesc(consensusParams, idx, height)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
|
@ -687,7 +718,15 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||||
" },\n"
|
" },\n"
|
||||||
" \"reject\": { ... } (object) progress toward rejecting pre-softfork blocks (same fields as \"enforce\")\n"
|
" \"reject\": { ... } (object) progress toward rejecting pre-softfork blocks (same fields as \"enforce\")\n"
|
||||||
" }, ...\n"
|
" }, ...\n"
|
||||||
" ]\n"
|
" ],\n"
|
||||||
|
" \"upgrades\": { (object) status of network upgrades\n"
|
||||||
|
" \"xxxx\" : { (string) branch ID of the upgrade\n"
|
||||||
|
" \"name\": \"xxxx\", (string) name of upgrade\n"
|
||||||
|
" \"activationheight\": xxxxxx, (numeric) block height of activation\n"
|
||||||
|
" \"status\": \"xxxx\", (string) status of upgrade\n"
|
||||||
|
" \"info\": \"xxxx\", (string) additional information about upgrade\n"
|
||||||
|
" }, ...\n"
|
||||||
|
" }\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("getblockchaininfo", "")
|
+ HelpExampleCli("getblockchaininfo", "")
|
||||||
|
@ -722,6 +761,12 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||||
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
|
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
|
||||||
obj.push_back(Pair("softforks", softforks));
|
obj.push_back(Pair("softforks", softforks));
|
||||||
|
|
||||||
|
UniValue upgrades(UniValue::VOBJ);
|
||||||
|
for (int i = Consensus::UPGRADE_OVERWINTER; i < Consensus::MAX_NETWORK_UPGRADES; i++) {
|
||||||
|
NetworkUpgradeDescPushBack(upgrades, consensusParams, Consensus::UpgradeIndex(i), tip->nHeight);
|
||||||
|
}
|
||||||
|
obj.push_back(Pair("upgrades", upgrades));
|
||||||
|
|
||||||
if (fPruneMode)
|
if (fPruneMode)
|
||||||
{
|
{
|
||||||
CBlockIndex *block = chainActive.Tip();
|
CBlockIndex *block = chainActive.Tip();
|
||||||
|
|
Loading…
Reference in New Issue