Show softfork status in getblockchaininfo
This commit is contained in:
parent
24f24896d6
commit
5ed10793c2
@ -469,6 +469,36 @@ UniValue verifychain(const UniValue& params, bool fHelp)
|
|||||||
return CVerifyDB().VerifyDB(pcoinsTip, nCheckLevel, nCheckDepth);
|
return CVerifyDB().VerifyDB(pcoinsTip, nCheckLevel, nCheckDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Implementation of IsSuperMajority with better feedback */
|
||||||
|
static UniValue SoftForkMajorityDesc(int minVersion, CBlockIndex* pindex, int nRequired, const Consensus::Params& consensusParams)
|
||||||
|
{
|
||||||
|
int nFound = 0;
|
||||||
|
CBlockIndex* pstart = pindex;
|
||||||
|
for (int i = 0; i < consensusParams.nMajorityWindow && pstart != NULL; i++)
|
||||||
|
{
|
||||||
|
if (pstart->nVersion >= minVersion)
|
||||||
|
++nFound;
|
||||||
|
pstart = pstart->pprev;
|
||||||
|
}
|
||||||
|
|
||||||
|
UniValue rv(UniValue::VOBJ);
|
||||||
|
rv.push_back(Pair("status", nFound >= nRequired));
|
||||||
|
rv.push_back(Pair("found", nFound));
|
||||||
|
rv.push_back(Pair("required", nRequired));
|
||||||
|
rv.push_back(Pair("window", consensusParams.nMajorityWindow));
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
static UniValue SoftForkDesc(const std::string &name, int version, CBlockIndex* pindex, const Consensus::Params& consensusParams)
|
||||||
|
{
|
||||||
|
UniValue rv(UniValue::VOBJ);
|
||||||
|
rv.push_back(Pair("id", name));
|
||||||
|
rv.push_back(Pair("version", version));
|
||||||
|
rv.push_back(Pair("enforce", SoftForkMajorityDesc(version, pindex, consensusParams.nMajorityEnforceBlockUpgrade, consensusParams)));
|
||||||
|
rv.push_back(Pair("reject", SoftForkMajorityDesc(version, pindex, consensusParams.nMajorityRejectBlockOutdated, consensusParams)));
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
@ -484,6 +514,19 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
|||||||
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
|
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
|
||||||
" \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
|
" \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
|
||||||
" \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n"
|
" \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n"
|
||||||
|
" \"softforks\": [ (array) status of softforks in progress\n"
|
||||||
|
" {\n"
|
||||||
|
" \"id\": \"xxxx\", (string) name of softfork\n"
|
||||||
|
" \"version\": xx, (numeric) block version\n"
|
||||||
|
" \"enforce\": { (object) progress toward enforcing the softfork rules for new-version blocks\n"
|
||||||
|
" \"status\": xx, (boolean) true if threshold reached\n"
|
||||||
|
" \"found\": xx, (numeric) number of blocks with the new version found\n"
|
||||||
|
" \"required\": xx, (numeric) number of blocks required to trigger\n"
|
||||||
|
" \"window\": xx, (numeric) maximum size of examined window of recent blocks\n"
|
||||||
|
" },\n"
|
||||||
|
" \"reject\": { ... } (object) progress toward rejecting pre-softfork blocks (same fields as \"enforce\")\n"
|
||||||
|
" }, ...\n"
|
||||||
|
" ]\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("getblockchaininfo", "")
|
+ HelpExampleCli("getblockchaininfo", "")
|
||||||
@ -501,6 +544,14 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
|||||||
obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip())));
|
obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip())));
|
||||||
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
|
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
|
||||||
obj.push_back(Pair("pruned", fPruneMode));
|
obj.push_back(Pair("pruned", fPruneMode));
|
||||||
|
|
||||||
|
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||||
|
CBlockIndex* tip = chainActive.Tip();
|
||||||
|
UniValue softforks(UniValue::VARR);
|
||||||
|
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
|
||||||
|
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
|
||||||
|
obj.push_back(Pair("softforks", softforks));
|
||||||
|
|
||||||
if (fPruneMode)
|
if (fPruneMode)
|
||||||
{
|
{
|
||||||
CBlockIndex *block = chainActive.Tip();
|
CBlockIndex *block = chainActive.Tip();
|
||||||
|
Loading…
Reference in New Issue
Block a user