@ -1667,6 +1667,18 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
int64_t nTimeStart = GetTimeMicros ( ) ;
// Check it again in case a previous version let a bad block in
// NOTE: We don't currently (re-)invoke ContextualCheckBlock() or
// ContextualCheckBlockHeader() here. This means that if we add a new
// consensus rule that is enforced in one of those two functions, then we
// may have let in a block that violates the rule prior to updating the
// software, and we would NOT be enforcing the rule here. Fully solving
// upgrade from one software version to the next after a consensus rule
// change is potentially tricky and issue-specific (see RewindBlockIndex()
// for one general approach that was used for BIP 141 deployment).
// Also, currently the rule against blocks more than 2 hours in the future
// is enforced in ContextualCheckBlockHeader(); we wouldn't want to
// re-enforce that rule here (at least until we make it impossible for
// GetAdjustedTime() to go backward).
if ( ! CheckBlock ( block , state , chainparams . GetConsensus ( ) , ! fJustCheck , ! fJustCheck ) )
return error ( " %s: Consensus::CheckBlock: %s " , __func__ , FormatStateMessage ( state ) ) ;
@ -2952,7 +2964,13 @@ std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBloc
/** Context-dependent validity checks.
* By " context " , we mean only the previous block headers , but not the UTXO
* set ; UTXO - related validity checks are done in ConnectBlock ( ) . */
* set ; UTXO - related validity checks are done in ConnectBlock ( ) .
* NOTE : This function is not currently invoked by ConnectBlock ( ) , so we
* should consider upgrade issues if we change which consensus rules are
* enforced in this function ( eg by adding a new consensus rule ) . See comment
* in ConnectBlock ( ) .
* Note that - reindex - chainstate skips the validation that happens here !
*/
static bool ContextualCheckBlockHeader ( const CBlockHeader & block , CValidationState & state , const CChainParams & params , const CBlockIndex * pindexPrev , int64_t nAdjustedTime )
{
assert ( pindexPrev ! = nullptr ) ;
@ -2992,6 +3010,12 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta
return true ;
}
/** NOTE: This function is not currently invoked by ConnectBlock(), so we
* should consider upgrade issues if we change which consensus rules are
* enforced in this function ( eg by adding a new consensus rule ) . See comment
* in ConnectBlock ( ) .
* Note that - reindex - chainstate skips the validation that happens here !
*/
static bool ContextualCheckBlock ( const CBlock & block , CValidationState & state , const Consensus : : Params & consensusParams , const CBlockIndex * pindexPrev )
{
const int nHeight = pindexPrev = = nullptr ? 0 : pindexPrev - > nHeight + 1 ;