mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
CorruptionPossible -> BLOCK_MUTATED
Co-authored-by: Anthony Towns <aj@erisian.com.au>
This commit is contained in:
parent
6e55b292b0
commit
9ab2a0412e
@ -203,7 +203,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
|
|||||||
// but that is expensive, and CheckBlock caches a block's
|
// but that is expensive, and CheckBlock caches a block's
|
||||||
// "checked-status" (in the CBlock?). CBlock should be able to
|
// "checked-status" (in the CBlock?). CBlock should be able to
|
||||||
// check its own merkle root and cache that check.
|
// check its own merkle root and cache that check.
|
||||||
if (state.CorruptionPossible())
|
if (state.GetReason() == ValidationInvalidReason::BLOCK_MUTATED)
|
||||||
return READ_STATUS_FAILED; // Possible Short ID collision
|
return READ_STATUS_FAILED; // Possible Short ID collision
|
||||||
return READ_STATUS_CHECKBLOCK_FAILED;
|
return READ_STATUS_CHECKBLOCK_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -1290,7 +1290,7 @@ void static InvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(c
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state) {
|
void CChainState::InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state) {
|
||||||
if (!state.CorruptionPossible()) {
|
if (state.GetReason() != ValidationInvalidReason::BLOCK_MUTATED) {
|
||||||
pindex->nStatus |= BLOCK_FAILED_VALID;
|
pindex->nStatus |= BLOCK_FAILED_VALID;
|
||||||
m_failed_blocks.insert(pindex);
|
m_failed_blocks.insert(pindex);
|
||||||
setDirtyBlockIndex.insert(pindex);
|
setDirtyBlockIndex.insert(pindex);
|
||||||
@ -1791,7 +1791,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
|
|||||||
// re-enforce that rule here (at least until we make it impossible for
|
// re-enforce that rule here (at least until we make it impossible for
|
||||||
// GetAdjustedTime() to go backward).
|
// GetAdjustedTime() to go backward).
|
||||||
if (!CheckBlock(block, state, chainparams.GetConsensus(), !fJustCheck, !fJustCheck)) {
|
if (!CheckBlock(block, state, chainparams.GetConsensus(), !fJustCheck, !fJustCheck)) {
|
||||||
if (state.CorruptionPossible()) {
|
if (state.GetReason() == ValidationInvalidReason::BLOCK_MUTATED) {
|
||||||
// We don't write down blocks to disk if they may have been
|
// We don't write down blocks to disk if they may have been
|
||||||
// corrupted, so this should be impossible unless we're having hardware
|
// corrupted, so this should be impossible unless we're having hardware
|
||||||
// problems.
|
// problems.
|
||||||
@ -2570,7 +2570,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
|
|||||||
if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : std::shared_ptr<const CBlock>(), connectTrace, disconnectpool)) {
|
if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : std::shared_ptr<const CBlock>(), connectTrace, disconnectpool)) {
|
||||||
if (state.IsInvalid()) {
|
if (state.IsInvalid()) {
|
||||||
// The block violates a consensus rule.
|
// The block violates a consensus rule.
|
||||||
if (!state.CorruptionPossible()) {
|
if (state.GetReason() != ValidationInvalidReason::BLOCK_MUTATED) {
|
||||||
InvalidChainFound(vpindexToConnect.front());
|
InvalidChainFound(vpindexToConnect.front());
|
||||||
}
|
}
|
||||||
state = CValidationState();
|
state = CValidationState();
|
||||||
@ -3509,7 +3509,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CVali
|
|||||||
|
|
||||||
if (!CheckBlock(block, state, chainparams.GetConsensus()) ||
|
if (!CheckBlock(block, state, chainparams.GetConsensus()) ||
|
||||||
!ContextualCheckBlock(block, state, chainparams.GetConsensus(), pindex->pprev)) {
|
!ContextualCheckBlock(block, state, chainparams.GetConsensus(), pindex->pprev)) {
|
||||||
if (state.IsInvalid() && !state.CorruptionPossible()) {
|
if (state.IsInvalid() && state.GetReason() != ValidationInvalidReason::BLOCK_MUTATED) {
|
||||||
pindex->nStatus |= BLOCK_FAILED_VALID;
|
pindex->nStatus |= BLOCK_FAILED_VALID;
|
||||||
setDirtyBlockIndex.insert(pindex);
|
setDirtyBlockIndex.insert(pindex);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user