From 012fc91511b153ce3fd3e9fb7bbed8f85fb1690e Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 26 Nov 2015 15:48:26 +0100 Subject: NotifyBlockTip signal: switch from hash (uint256) to CBlockIndex* - also adds a boolean for indication if the tip update was happening during initial sync - emit notification also during initial sync --- src/init.cpp | 7 +++++-- src/main.cpp | 4 +++- src/ui_interface.h | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 1c2f3f49d4..8710e37fed 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -515,11 +515,14 @@ std::string LicenseInfo() "\n"; } -static void BlockNotifyCallback(const uint256& hashNewTip) +static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex) { + if (initialSync || !pBlockIndex) + return; + std::string strCmd = GetArg("-blocknotify", ""); - boost::replace_all(strCmd, "%s", hashNewTip.GetHex()); + boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); boost::thread t(runCommand, strCmd); // thread runs free } diff --git a/src/main.cpp b/src/main.cpp index 31913956b7..b41c1ad2e1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2636,9 +2636,11 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, // Notify external listeners about the new tip. if (!vHashes.empty()) { GetMainSignals().UpdatedBlockTip(pindexNewTip); - uiInterface.NotifyBlockTip(vHashes.front()); } } + if (!vHashes.empty()) { + uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip); + } } while(pindexMostWork != chainActive.Tip()); CheckBlockIndex(chainparams.GetConsensus()); diff --git a/src/ui_interface.h b/src/ui_interface.h index e402479933..00d9303124 100644 --- a/src/ui_interface.h +++ b/src/ui_interface.h @@ -15,6 +15,7 @@ class CBasicKeyStore; class CWallet; class uint256; +class CBlockIndex; /** General change type (added, updated, removed). */ enum ChangeType @@ -94,7 +95,7 @@ public: boost::signals2::signal ShowProgress; /** New block has been accepted */ - boost::signals2::signal NotifyBlockTip; + boost::signals2::signal NotifyBlockTip; /** Banlist did change. */ boost::signals2::signal BannedListChanged; -- cgit v1.2.3