Only call NotifyBlockTip when the active chain changes

Previously, if `invalidateblock` was called on a block in a branch,
NotifyBlockTip would be called on that block's predecessor, creating an
incorrect `rpc/blockchain.cpp:latestblock` value.

Only call NotifyBlockTip if the chain being modified is activeChain.
This commit is contained in:
James O'Beirne 2018-02-13 22:39:04 -05:00
parent 152b7fb25f
commit f98b543522

View file

@ -2731,7 +2731,11 @@ bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& c
}
InvalidChainFound(pindex);
uiInterface.NotifyBlockTip(IsInitialBlockDownload(), pindex->pprev);
// Only notify about a new block tip if the active chain was modified.
if (pindex_was_in_chain) {
uiInterface.NotifyBlockTip(IsInitialBlockDownload(), pindex->pprev);
}
return true;
}
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex *pindex) {