Skip to content

Commit 12ee1fe

Browse files
committed
Always call UpdatedBlockTip, even if blocks were only disconnected
1 parent f5efa28 commit 12ee1fe

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/main.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3028,7 +3028,6 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
30283028
const CBlockIndex *pindexFork;
30293029
std::list<CTransaction> txConflicted;
30303030
bool fInitialDownload;
3031-
int nNewHeight;
30323031
{
30333032
LOCK(cs_main);
30343033
CBlockIndex *pindexOldTip = chainActive.Tip();
@@ -3051,13 +3050,10 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
30513050
pindexNewTip = chainActive.Tip();
30523051
pindexFork = chainActive.FindFork(pindexOldTip);
30533052
fInitialDownload = IsInitialBlockDownload();
3054-
nNewHeight = chainActive.Height();
30553053
}
30563054
// When we reach this point, we switched to a new tip (stored in pindexNewTip).
30573055

30583056
// Notifications/callbacks that can run without cs_main
3059-
if(connman)
3060-
connman->SetBestHeight(nNewHeight);
30613057

30623058
// throw all transactions though the signal-interface
30633059
// while _not_ holding the cs_main lock
@@ -3069,12 +3065,12 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
30693065
for(unsigned int i = 0; i < txChanged.size(); i++)
30703066
SyncWithWallets(std::get<0>(txChanged[i]), std::get<1>(txChanged[i]), std::get<2>(txChanged[i]));
30713067

3068+
// Notify external listeners about the new tip.
3069+
GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload);
3070+
30723071
// Always notify the UI if a new block tip was connected
30733072
if (pindexFork != pindexNewTip) {
30743073
uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip);
3075-
3076-
// Notify external listeners about the new tip.
3077-
GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload);
30783074
}
30793075
} while (pindexNewTip != pindexMostWork);
30803076
CheckBlockIndex(chainparams.GetConsensus());
@@ -4665,6 +4661,7 @@ std::string GetWarnings(const std::string& strFor)
46654661

46664662
void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {
46674663
const int nNewHeight = pindexNew->nHeight;
4664+
connman->SetBestHeight(nNewHeight);
46684665

46694666
if (!fInitialDownload) {
46704667
// Find the hashes of all blocks that weren't previously in the best chain.

src/zmq/zmqnotificationinterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void CZMQNotificationInterface::Shutdown()
126126

127127
void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
128128
{
129-
if (fInitialDownload)
129+
if (fInitialDownload || pindexNew == pindexFork) // In IBD or blocks were disconnected without any new ones
130130
return;
131131

132132
for (std::list<CZMQAbstractNotifier*>::iterator i = notifiers.begin(); i!=notifiers.end(); )

0 commit comments

Comments
 (0)