From 39ee63c87695b013d3311dfeab136d8c2031f2c5 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 11 Apr 2018 21:46:58 -0600 Subject: [PATCH] When rewinding, reset pindexBestInvalid if it is pointing to a removed block --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 766369344..587032547 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4058,6 +4058,10 @@ bool RewindBlockIndex(const CChainParams& params) if (!sufficientlyValidated(pindexIter) && !chainActive.Contains(pindexIter)) { // Add to the list of blocks to remove vBlocks.push_back(pindexIter); + if (pindexIter == pindexBestInvalid) { + // Reset invalid block marker if it was pointing to this block + pindexBestInvalid = NULL; + } // Update indices setBlockIndexCandidates.erase(pindexIter); auto ret = mapBlocksUnlinked.equal_range(pindexIter->pprev);