Bugfix: the end of a reorged chain is invalid when connect fails
Introduced in 4e0eed88ac
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.
This commit is contained in:
parent
bf9b03ddcc
commit
a2f678d355
1 changed files with 3 additions and 2 deletions
|
@ -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 (!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.CorruptionPossible()) {
|
||||||
InvalidChainFound(vpindexToConnect.back());
|
InvalidChainFound(vpindexToConnect.front());
|
||||||
|
}
|
||||||
state = CValidationState();
|
state = CValidationState();
|
||||||
fInvalidFound = true;
|
fInvalidFound = true;
|
||||||
fContinue = false;
|
fContinue = false;
|
||||||
|
|
Loading…
Reference in a new issue