Skip to content

Commit f98b543

Browse files
committed
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.
1 parent 152b7fb commit f98b543

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/validation.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2731,7 +2731,11 @@ bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& c
27312731
}
27322732

27332733
InvalidChainFound(pindex);
2734-
uiInterface.NotifyBlockTip(IsInitialBlockDownload(), pindex->pprev);
2734+
2735+
// Only notify about a new block tip if the active chain was modified.
2736+
if (pindex_was_in_chain) {
2737+
uiInterface.NotifyBlockTip(IsInitialBlockDownload(), pindex->pprev);
2738+
}
27352739
return true;
27362740
}
27372741
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex *pindex) {

0 commit comments

Comments
 (0)