diff --git a/src/interfaces/node.h b/src/interfaces/node.h --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -254,9 +254,8 @@ handleNotifyBlockTip(NotifyBlockTipFn fn) = 0; //! Register handler for header tip messages. - using NotifyHeaderTipFn = - std::function; + using NotifyHeaderTipFn = std::function; virtual std::unique_ptr handleNotifyHeaderTip(NotifyHeaderTipFn fn) = 0; diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -352,12 +352,10 @@ handleNotifyHeaderTip(NotifyHeaderTipFn fn) override { /* verification progress is unused when a header was received */ return MakeHandler(::uiInterface.NotifyHeaderTip_connect( - [fn](SynchronizationState sync_state, - const CBlockIndex *block) { + [fn](SynchronizationState sync_state, int64_t height, + int64_t timestamp, bool presync) { fn(sync_state, - BlockTip{block->nHeight, block->GetBlockTime(), - block->GetBlockHash()}, - 0); + BlockTip{int(height), timestamp, BlockHash{}}, presync); })); } NodeContext *context() override { return m_context; } diff --git a/src/node/ui_interface.h b/src/node/ui_interface.h --- a/src/node/ui_interface.h +++ b/src/node/ui_interface.h @@ -127,7 +127,7 @@ /** Best header has changed */ ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, SynchronizationState, - const CBlockIndex *); + int64_t height, int64_t timestamp, bool presync); /** Banlist did change. */ ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void); diff --git a/src/node/ui_interface.cpp b/src/node/ui_interface.cpp --- a/src/node/ui_interface.cpp +++ b/src/node/ui_interface.cpp @@ -85,9 +85,9 @@ const CBlockIndex *i) { return g_ui_signals.NotifyBlockTip(s, i); } -void CClientUIInterface::NotifyHeaderTip(SynchronizationState s, - const CBlockIndex *i) { - return g_ui_signals.NotifyHeaderTip(s, i); +void CClientUIInterface::NotifyHeaderTip(SynchronizationState s, int64_t height, + int64_t timestamp, bool presync) { + return g_ui_signals.NotifyHeaderTip(s, height, timestamp, presync); } void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -249,8 +249,11 @@ }); m_handler_notify_header_tip = m_node.handleNotifyHeaderTip( [this](SynchronizationState sync_state, interfaces::BlockTip tip, - double verification_progress) { - TipChanged(sync_state, tip, verification_progress, /*header=*/true); + bool presync) { + if (!presync) { + TipChanged(sync_state, tip, /*verification_progress=*/0.0, + /*header=*/true); + } }); } diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3099,7 +3099,8 @@ // Send block tip changed notifications without cs_main if (fNotify) { uiInterface.NotifyHeaderTip( - GetSynchronizationState(fInitialBlockDownload), pindexHeader); + GetSynchronizationState(fInitialBlockDownload), + pindexHeader->nHeight, pindexHeader->nTime, false); } return fNotify; } @@ -4311,7 +4312,10 @@ } m_last_presync_update = now; } - if (chainstate.IsInitialBlockDownload()) { + bool initial_download = chainstate.IsInitialBlockDownload(); + uiInterface.NotifyHeaderTip(GetSynchronizationState(initial_download), + height, timestamp, /*presync=*/true); + if (initial_download) { const int64_t blocks_left{(GetTime() - timestamp) / GetConsensus().nPowTargetSpacing}; const double progress{100.0 * height / (height + blocks_left)};