@@ -3187,7 +3187,7 @@ static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidation
3187
3187
}
3188
3188
if (fNewBlock ) *fNewBlock = true ;
3189
3189
3190
- if (!CheckBlock (block, state, chainparams.GetConsensus (), GetAdjustedTime () ) ||
3190
+ if (!CheckBlock (block, state, chainparams.GetConsensus ()) ||
3191
3191
!ContextualCheckBlock (block, state, chainparams.GetConsensus (), pindex->pprev )) {
3192
3192
if (state.IsInvalid () && !state.CorruptionPossible ()) {
3193
3193
pindex->nStatus |= BLOCK_FAILED_VALID;
@@ -3229,13 +3229,19 @@ static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidation
3229
3229
bool ProcessNewBlock (const CChainParams& chainparams, const std::shared_ptr<const CBlock> pblock, bool fForceProcessing , bool *fNewBlock )
3230
3230
{
3231
3231
{
3232
- LOCK (cs_main);
3233
-
3234
- // Store to disk
3235
3232
CBlockIndex *pindex = NULL ;
3236
3233
if (fNewBlock ) *fNewBlock = false ;
3237
3234
CValidationState state;
3238
- bool ret = AcceptBlock (pblock, state, chainparams, &pindex, fForceProcessing , NULL , fNewBlock );
3235
+ // Ensure that CheckBlock() passes before calling AcceptBlock, as
3236
+ // belt-and-suspenders.
3237
+ bool ret = CheckBlock (*pblock, state, chainparams.GetConsensus ());
3238
+
3239
+ LOCK (cs_main);
3240
+
3241
+ if (ret) {
3242
+ // Store to disk
3243
+ ret = AcceptBlock (pblock, state, chainparams, &pindex, fForceProcessing , NULL , fNewBlock );
3244
+ }
3239
3245
CheckBlockIndex (chainparams.GetConsensus ());
3240
3246
if (!ret) {
3241
3247
GetMainSignals ().BlockChecked (*pblock, state);
0 commit comments