diff options
author | James O'Beirne <james.obeirne@gmail.com> | 2018-02-13 22:39:04 -0500 |
---|---|---|
committer | James O'Beirne <james.obeirne@gmail.com> | 2018-02-16 11:50:22 -0500 |
commit | f98b543522687a4ff93ad7d53fa3cc67b5c6d752 (patch) | |
tree | 5f01b3b4ec9c7a58a7374575c1ef2ca1692f3d82 /src/validation.cpp | |
parent | 152b7fb25fc1e5255ab038a8a3f6a3ce1c540892 (diff) |
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.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index d9e877f2eb..6b96344d36 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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) { |