mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-10-21 06:18:39 +02:00
fix a bug in CheckBlockHeader that was introduced with the AuxPow changes.
We were doing checkpoint checks in CheckBlockHeader, this caused the wallet to flag the blockchain as corrupt if the last checkpoint is within -checkblocks (default is 288) blocks of what is already stored in the local blockchain. The checks are completed in ProcessBlock - this is where it was done in 0.9.2.15 and prior, and bitcoin 0.9.2 upwards does the same. see https://github.com/bitcoin/bitcoin/issues/4246 and resulting commit https://github.com/sipa/bitcoin/commit/7a9e0b6460037b72376af293dc87acafe4fca831 for similar issue found during bitcoin 0.10 development.
This commit is contained in:
@@ -2578,28 +2578,6 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, int nH
|
||||
return state.Invalid(error("CheckBlockHeader() : block timestamp too far in the future"),
|
||||
REJECT_INVALID, "time-too-new");
|
||||
|
||||
CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex);
|
||||
if (pcheckpoint && block.hashPrevBlock != (chainActive.Tip() ? chainActive.Tip()->GetBlockHash() : uint256(0)))
|
||||
{
|
||||
// Extra checks to prevent "fill up memory by spamming with bogus blocks"
|
||||
int64_t deltaTime = block.GetBlockTime() - pcheckpoint->nTime;
|
||||
if (deltaTime < 0)
|
||||
{
|
||||
LogPrintf("CheckBlockHeader(): Height=%d, hash=%s, BlockTime=%d, Checkpoint=%d\n", nHeight, block.GetHash().GetHex().c_str(), block.GetBlockTime(), pcheckpoint->nTime);
|
||||
return state.DoS(100, error("CheckBlockHeader() : block with timestamp before last checkpoint"),
|
||||
REJECT_CHECKPOINT, "time-too-old");
|
||||
}
|
||||
CBigNum bnNewBlock;
|
||||
bnNewBlock.SetCompact(block.nBits);
|
||||
CBigNum bnRequired;
|
||||
bnRequired.SetCompact(ComputeMinWork(pcheckpoint->nBits, deltaTime));
|
||||
if (bnNewBlock > bnRequired)
|
||||
{
|
||||
return state.DoS(100, error("CheckBlockHeader() : block with too little proof-of-work"),
|
||||
REJECT_INVALID, "bad-diffbits");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user