| 553 | } |
| 554 | |
| 555 | bool InvalidateBlock(CValidationState &state, CBlockIndex *pIndex) { |
| 556 | AssertLockHeld(cs_main); |
| 557 | |
| 558 | // Mark the block itself as invalid. |
| 559 | if (!InvalidateBlockIndex(pIndex)) { |
| 560 | return ERRORMSG("invalidate block=%s index failed", pIndex->GetIdString()); |
| 561 | } |
| 562 | |
| 563 | while (chainActive.Contains(pIndex)) { |
| 564 | if (!InvalidateBlockIndex(chainActive.Tip())) { |
| 565 | return ERRORMSG("invalidate block=%s index failed", pIndex->GetIdString()); |
| 566 | } |
| 567 | // ActivateBestChain considers blocks already in chainActive |
| 568 | // unconditionally valid already, so force disconnect away from it. |
| 569 | if (!DisconnectTip(state)) { |
| 570 | return false; |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | InvalidChainFound(pIndex); |
| 575 | return true; |
| 576 | } |
| 577 | |
| 578 | |
| 579 | bool ReconsiderBlockIndex(CBlockIndex *pIndex) { |
no test coverage detected