Protect height 1

This commit is contained in:
jl777
2018-06-27 06:53:12 -11:00
parent 76f3c7e5c2
commit 9aa708afb8

View File

@@ -4060,7 +4060,9 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
// Don't accept any forks from the main chain prior to last checkpoint // Don't accept any forks from the main chain prior to last checkpoint
CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints()); CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints());
int32_t notarized_height; int32_t notarized_height;
if (pcheckpoint && nHeight > 1 && nHeight < pcheckpoint->nHeight ) if ( pcheckpoint && nHeight > 1 )
{
if (nHeight < pcheckpoint->nHeight )
return state.DoS(1, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight)); return state.DoS(1, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight));
else if ( komodo_checkpoint(&notarized_height,nHeight,hash) < 0 ) else if ( komodo_checkpoint(&notarized_height,nHeight,hash) < 0 )
{ {
@@ -4072,6 +4074,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
} else return state.DoS(1, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height)); } else return state.DoS(1, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height));
} }
} }
}
// Reject block.nVersion < 4 blocks // Reject block.nVersion < 4 blocks
if (block.nVersion < 4) if (block.nVersion < 4)
return state.Invalid(error("%s : rejected nVersion<4 block", __func__), return state.Invalid(error("%s : rejected nVersion<4 block", __func__),