@@ -469,6 +469,36 @@ UniValue verifychain(const UniValue& params, bool fHelp)
469469 return CVerifyDB ().VerifyDB (pcoinsTip, nCheckLevel, nCheckDepth);
470470}
471471
472+ /* * Implementation of IsSuperMajority with better feedback */
473+ static UniValue SoftForkMajorityDesc (int minVersion, CBlockIndex* pindex, int nRequired, const Consensus::Params& consensusParams)
474+ {
475+ int nFound = 0 ;
476+ CBlockIndex* pstart = pindex;
477+ for (int i = 0 ; i < consensusParams.nMajorityWindow && pstart != NULL ; i++)
478+ {
479+ if (pstart->nVersion >= minVersion)
480+ ++nFound;
481+ pstart = pstart->pprev ;
482+ }
483+
484+ UniValue rv (UniValue::VOBJ);
485+ rv.push_back (Pair (" status" , nFound >= nRequired));
486+ rv.push_back (Pair (" found" , nFound));
487+ rv.push_back (Pair (" required" , nRequired));
488+ rv.push_back (Pair (" window" , consensusParams.nMajorityWindow ));
489+ return rv;
490+ }
491+
492+ static UniValue SoftForkDesc (const std::string &name, int version, CBlockIndex* pindex, const Consensus::Params& consensusParams)
493+ {
494+ UniValue rv (UniValue::VOBJ);
495+ rv.push_back (Pair (" id" , name));
496+ rv.push_back (Pair (" version" , version));
497+ rv.push_back (Pair (" enforce" , SoftForkMajorityDesc (version, pindex, consensusParams.nMajorityEnforceBlockUpgrade , consensusParams)));
498+ rv.push_back (Pair (" reject" , SoftForkMajorityDesc (version, pindex, consensusParams.nMajorityRejectBlockOutdated , consensusParams)));
499+ return rv;
500+ }
501+
472502UniValue getblockchaininfo (const UniValue& params, bool fHelp )
473503{
474504 if (fHelp || params.size () != 0 )
@@ -484,6 +514,19 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
484514 " \" difficulty\" : xxxxxx, (numeric) the current difficulty\n "
485515 " \" verificationprogress\" : xxxx, (numeric) estimate of verification progress [0..1]\n "
486516 " \" chainwork\" : \" xxxx\" (string) total amount of work in active chain, in hexadecimal\n "
517+ " \" softforks\" : [ (array) status of softforks in progress\n "
518+ " {\n "
519+ " \" id\" : \" xxxx\" , (string) name of softfork\n "
520+ " \" version\" : xx, (numeric) block version\n "
521+ " \" enforce\" : { (object) progress toward enforcing the softfork rules for new-version blocks\n "
522+ " \" status\" : xx, (boolean) true if threshold reached\n "
523+ " \" found\" : xx, (numeric) number of blocks with the new version found\n "
524+ " \" required\" : xx, (numeric) number of blocks required to trigger\n "
525+ " \" window\" : xx, (numeric) maximum size of examined window of recent blocks\n "
526+ " },\n "
527+ " \" reject\" : { ... } (object) progress toward rejecting pre-softfork blocks (same fields as \" enforce\" )\n "
528+ " }, ...\n "
529+ " ]\n "
487530 " }\n "
488531 " \n Examples:\n "
489532 + HelpExampleCli (" getblockchaininfo" , " " )
@@ -501,6 +544,14 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
501544 obj.push_back (Pair (" verificationprogress" , Checkpoints::GuessVerificationProgress (Params ().Checkpoints (), chainActive.Tip ())));
502545 obj.push_back (Pair (" chainwork" , chainActive.Tip ()->nChainWork .GetHex ()));
503546 obj.push_back (Pair (" pruned" , fPruneMode ));
547+
548+ const Consensus::Params& consensusParams = Params ().GetConsensus ();
549+ CBlockIndex* tip = chainActive.Tip ();
550+ UniValue softforks (UniValue::VARR);
551+ softforks.push_back (SoftForkDesc (" bip34" , 2 , tip, consensusParams));
552+ softforks.push_back (SoftForkDesc (" bip66" , 3 , tip, consensusParams));
553+ obj.push_back (Pair (" softforks" , softforks));
554+
504555 if (fPruneMode )
505556 {
506557 CBlockIndex *block = chainActive.Tip ();
0 commit comments