mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-03 07:52:33 +02:00
fix: force checkpoint
This commit is contained in:
parent
91b7760dd9
commit
c834c7dbf9
@ -26,6 +26,12 @@ struct CCheckpointData {
|
||||
const auto& final_checkpoint = mapCheckpoints.rbegin();
|
||||
return final_checkpoint->first /* height */;
|
||||
}
|
||||
|
||||
const uint256 GetHash() const {
|
||||
const auto& final_checkpoint = mapCheckpoints.rbegin();
|
||||
return final_checkpoint->second /* hash */;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct AssumeutxoHash : public BaseHash<uint256> {
|
||||
|
@ -3473,11 +3473,18 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
|
||||
// Don't accept any forks from the main chain prior to last checkpoint.
|
||||
// GetLastCheckpoint finds the last checkpoint in MapCheckpoints that's in our
|
||||
// BlockIndex().
|
||||
const CBlockIndex* pcheckpoint = blockman.GetLastCheckpoint(chainman.GetParams().Checkpoints());
|
||||
|
||||
const CCheckpointData& checkpointdata = chainman.GetParams().Checkpoints();
|
||||
const CBlockIndex* pcheckpoint = blockman.GetLastCheckpoint(checkpointdata);
|
||||
if (pcheckpoint && nHeight < pcheckpoint->nHeight) {
|
||||
LogPrintf("ERROR: %s: forked chain older than last checkpoint (height %d)\n", __func__, nHeight);
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CHECKPOINT, "bad-fork-prior-to-checkpoint");
|
||||
}
|
||||
|
||||
if (nHeight == checkpointdata.GetHeight() && block.GetHash() != checkpointdata.GetHash()) {
|
||||
LogPrintf("ERROR: %s: forked chain on last checkpoint (height %d)\n", __func__, nHeight);
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CHECKPOINT, "bad-fork-to-checkpoint");
|
||||
}
|
||||
}
|
||||
|
||||
// Check timestamp against prev
|
||||
|
Loading…
Reference in New Issue
Block a user