Skip to content

Commit 08c1caf

Browse files
committed
Merge #13185: Bugfix: the end of a reorged chain is invalid when 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
2 parents 612ba35 + a2f678d commit 08c1caf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/validation.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,8 +2551,9 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
25512551
if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : std::shared_ptr<const CBlock>(), connectTrace, disconnectpool)) {
25522552
if (state.IsInvalid()) {
25532553
// The block violates a consensus rule.
2554-
if (!state.CorruptionPossible())
2555-
InvalidChainFound(vpindexToConnect.back());
2554+
if (!state.CorruptionPossible()) {
2555+
InvalidChainFound(vpindexToConnect.front());
2556+
}
25562557
state = CValidationState();
25572558
fInvalidFound = true;
25582559
fContinue = false;

0 commit comments

Comments
 (0)