Skip to content

Commit

Permalink
Merge bitcoin#13185: Bugfix: the end of a reorged chain is invalid wh…
Browse files Browse the repository at this point in the history
…en connect fails

a2f678d Bugfix: the end of a reorged chain is invalid when connect fails (Pieter Wuille)

Pull request description:

  Introduced in 4e0eed8

  When an invalid block is found during a reorg, we know the last of the blocks in the was-to-be-connected chain is invalid, but not necessarily the first. As `vpIndexToConnect` is ordered in decreasing height, the end of the reorg is the front of the vector, and not the back.

  This only affected the warning system.

Tree-SHA512: ddf749f8a78083811a5a17152723f545c1463768d09dc9832ec3682e803a3c106fb768de9fa91c03aa95e644d4e41361a7e4ee791940fd7d51cdefea90de31fc
  • Loading branch information
laanwj authored and PastaPastaPasta committed Jun 27, 2020
1 parent 0425b71 commit ead19bb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2866,8 +2866,9 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : std::shared_ptr<const CBlock>(), connectTrace, disconnectpool)) {
if (state.IsInvalid()) {
// The block violates a consensus rule.
if (!state.CorruptionPossible())
InvalidChainFound(vpindexToConnect.back());
if (!state.CorruptionPossible()) {
InvalidChainFound(vpindexToConnect.front());
}
state = CValidationState();
fInvalidFound = true;
fContinue = false;
Expand Down

0 comments on commit ead19bb

Please sign in to comment.