Browse Source

Always call UpdatedBlockTip, even if blocks were only disconnected

0.14
Matt Corallo 8 years ago
parent
commit
12ee1fe018
  1. 11
      src/main.cpp
  2. 2
      src/zmq/zmqnotificationinterface.cpp

11
src/main.cpp

@ -3028,7 +3028,6 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, @@ -3028,7 +3028,6 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
const CBlockIndex *pindexFork;
std::list<CTransaction> txConflicted;
bool fInitialDownload;
int nNewHeight;
{
LOCK(cs_main);
CBlockIndex *pindexOldTip = chainActive.Tip();
@ -3051,13 +3050,10 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, @@ -3051,13 +3050,10 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
pindexNewTip = chainActive.Tip();
pindexFork = chainActive.FindFork(pindexOldTip);
fInitialDownload = IsInitialBlockDownload();
nNewHeight = chainActive.Height();
}
// When we reach this point, we switched to a new tip (stored in pindexNewTip).
// Notifications/callbacks that can run without cs_main
if(connman)
connman->SetBestHeight(nNewHeight);
// throw all transactions though the signal-interface
// while _not_ holding the cs_main lock
@ -3069,12 +3065,12 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, @@ -3069,12 +3065,12 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
for(unsigned int i = 0; i < txChanged.size(); i++)
SyncWithWallets(std::get<0>(txChanged[i]), std::get<1>(txChanged[i]), std::get<2>(txChanged[i]));
// Notify external listeners about the new tip.
GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload);
// Always notify the UI if a new block tip was connected
if (pindexFork != pindexNewTip) {
uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip);
// Notify external listeners about the new tip.
GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload);
}
} while (pindexNewTip != pindexMostWork);
CheckBlockIndex(chainparams.GetConsensus());
@ -4665,6 +4661,7 @@ std::string GetWarnings(const std::string& strFor) @@ -4665,6 +4661,7 @@ std::string GetWarnings(const std::string& strFor)
void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {
const int nNewHeight = pindexNew->nHeight;
connman->SetBestHeight(nNewHeight);
if (!fInitialDownload) {
// Find the hashes of all blocks that weren't previously in the best chain.

2
src/zmq/zmqnotificationinterface.cpp

@ -126,7 +126,7 @@ void CZMQNotificationInterface::Shutdown() @@ -126,7 +126,7 @@ void CZMQNotificationInterface::Shutdown()
void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
{
if (fInitialDownload)
if (fInitialDownload || pindexNew == pindexFork) // In IBD or blocks were disconnected without any new ones
return;
for (std::list<CZMQAbstractNotifier*>::iterator i = notifiers.begin(); i!=notifiers.end(); )

Loading…
Cancel
Save