@@ -469,6 +469,36 @@ UniValue verifychain(const UniValue& params, bool fHelp)
469
469
return CVerifyDB ().VerifyDB (pcoinsTip, nCheckLevel, nCheckDepth);
470
470
}
471
471
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
+
472
502
UniValue getblockchaininfo (const UniValue& params, bool fHelp )
473
503
{
474
504
if (fHelp || params.size () != 0 )
@@ -484,6 +514,19 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
484
514
" \" difficulty\" : xxxxxx, (numeric) the current difficulty\n "
485
515
" \" verificationprogress\" : xxxx, (numeric) estimate of verification progress [0..1]\n "
486
516
" \" 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 "
487
530
" }\n "
488
531
" \n Examples:\n "
489
532
+ HelpExampleCli (" getblockchaininfo" , " " )
@@ -501,6 +544,14 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
501
544
obj.push_back (Pair (" verificationprogress" , Checkpoints::GuessVerificationProgress (Params ().Checkpoints (), chainActive.Tip ())));
502
545
obj.push_back (Pair (" chainwork" , chainActive.Tip ()->nChainWork .GetHex ()));
503
546
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
+
504
555
if (fPruneMode )
505
556
{
506
557
CBlockIndex *block = chainActive.Tip ();
0 commit comments