@@ -67,6 +67,13 @@ map<uint256, COrphanTx> mapOrphanTransactions;
6767map<uint256, set<uint256> > mapOrphanTransactionsByPrev;
6868void EraseOrphansFor (NodeId peer);
6969
70+ /* *
71+ * Returns true if there are nRequired or more blocks of minVersion or above
72+ * in the last Params().ToCheckBlockUpgradeMajority() blocks, starting at pstart
73+ * and going backwards.
74+ */
75+ static bool IsSuperMajority (int minVersion, const CBlockIndex* pstart, unsigned int nRequired);
76+
7077/* * Constant stuff for coinbase transactions we create: */
7178CScript COINBASE_FLAGS;
7279
@@ -2479,8 +2486,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
24792486 return state.DoS (100 , error (" %s : forked chain older than last checkpoint (height %d)" , __func__, nHeight));
24802487
24812488 // Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
2482- if (block.nVersion < 2 &&
2483- CBlockIndex::IsSuperMajority (2 , pindexPrev, Params ().RejectBlockOutdatedMajority ()))
2489+ if (block.nVersion < 2 && IsSuperMajority (2 , pindexPrev, Params ().RejectBlockOutdatedMajority ()))
24842490 {
24852491 return state.Invalid (error (" %s : rejected nVersion=1 block" , __func__),
24862492 REJECT_OBSOLETE, " bad-version" );
@@ -2501,8 +2507,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
25012507
25022508 // Enforce block.nVersion=2 rule that the coinbase starts with serialized block height
25032509 // if 750 of the last 1,000 blocks are version 2 or greater (51/100 if testnet):
2504- if (block.nVersion >= 2 &&
2505- CBlockIndex::IsSuperMajority (2 , pindexPrev, Params ().EnforceBlockUpgradeMajority ()))
2510+ if (block.nVersion >= 2 && IsSuperMajority (2 , pindexPrev, Params ().EnforceBlockUpgradeMajority ()))
25062511 {
25072512 CScript expect = CScript () << nHeight;
25082513 if (block.vtx [0 ].vin [0 ].scriptSig .size () < expect.size () ||
@@ -2600,7 +2605,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
26002605 return true ;
26012606}
26022607
2603- bool CBlockIndex:: IsSuperMajority (int minVersion, const CBlockIndex* pstart, unsigned int nRequired)
2608+ static bool IsSuperMajority (int minVersion, const CBlockIndex* pstart, unsigned int nRequired)
26042609{
26052610 unsigned int nToCheck = Params ().ToCheckBlockUpgradeMajority ();
26062611 unsigned int nFound = 0 ;
0 commit comments