aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2018-05-07 11:18:27 -0700
committerPieter Wuille <[email protected]>2018-05-07 11:18:30 -0700
commita2f678d3552aaaaa8d6f480cf5f2fbc849f376c3 (patch)
treea1eef53fd2db841091b5bc91c562ffcb11b4d332 /src/validation.cpp
parentMerge #13094: tests: Add test for 64-bit Windows PE, modify 32-bit test results (diff)
downloaddiscoin-a2f678d3552aaaaa8d6f480cf5f2fbc849f376c3.tar.xz
discoin-a2f678d3552aaaaa8d6f480cf5f2fbc849f376c3.zip
Bugfix: the end of a reorged chain is invalid when connect fails
Introduced in 4e0eed88acdd41826868c151373068bfad18b84d 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.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index fc1f6477d..8a941561b 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2551,8 +2551,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;