Skip to content

Commit b7910a8

Browse files
sipafurszy
authored andcommitted
Bugfix: the end of a reorged chain is invalid when connect fails
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.
1 parent 22872bb commit b7910a8

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
@@ -2287,8 +2287,9 @@ static bool ActivateBestChainStep(CValidationState& state, CBlockIndex* pindexMo
22872287
if (!ConnectTip(state, pindexConnect, (pindexConnect == pindexMostWork) ? pblock : std::shared_ptr<const CBlock>(), connectTrace, disconnectpool)) {
22882288
if (state.IsInvalid()) {
22892289
// The block violates a consensus rule.
2290-
if (!state.CorruptionPossible())
2291-
InvalidChainFound(vpindexToConnect.back());
2290+
if (!state.CorruptionPossible()) {
2291+
InvalidChainFound(vpindexToConnect.front());
2292+
}
22922293
state = CValidationState();
22932294
fInvalidFound = true;
22942295
fContinue = false;

0 commit comments

Comments
 (0)