diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp index 91acc34054c..a184d64ff00 100644 --- a/src/bitcoin-chainstate.cpp +++ b/src/bitcoin-chainstate.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -89,6 +90,10 @@ int main(int argc, char* argv[]) { std::cout << "Block tip changed" << std::endl; } + void headerTip(SynchronizationState, int64_t height, int64_t timestamp, bool presync) override + { + std::cout << "Header tip changed: " << height << ", " << timestamp << ", " << presync << std::endl; + } }; auto notifications = std::make_unique(); diff --git a/src/kernel/notifications_interface.h b/src/kernel/notifications_interface.h index d90284fbea6..7f88176d03c 100644 --- a/src/kernel/notifications_interface.h +++ b/src/kernel/notifications_interface.h @@ -5,6 +5,8 @@ #ifndef BITCOIN_KERNEL_NOTIFICATIONS_INTERFACE_H #define BITCOIN_KERNEL_NOTIFICATIONS_INTERFACE_H +#include + class CBlockIndex; enum class SynchronizationState; @@ -20,6 +22,7 @@ public: virtual ~Notifications(){}; virtual void blockTip(SynchronizationState state, CBlockIndex& index) {} + virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {} }; } // namespace kernel diff --git a/src/node/kernel_notifications.cpp b/src/node/kernel_notifications.cpp index b710d0c5dbd..1e4bc20f2f9 100644 --- a/src/node/kernel_notifications.cpp +++ b/src/node/kernel_notifications.cpp @@ -13,4 +13,9 @@ void KernelNotifications::blockTip(SynchronizationState state, CBlockIndex& inde uiInterface.NotifyBlockTip(state, &index); } +void KernelNotifications::headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) +{ + uiInterface.NotifyHeaderTip(state, height, timestamp, presync); +} + } // namespace node diff --git a/src/node/kernel_notifications.h b/src/node/kernel_notifications.h index 11b270f1dbf..1507c3214a2 100644 --- a/src/node/kernel_notifications.h +++ b/src/node/kernel_notifications.h @@ -7,6 +7,8 @@ #include +#include + class CBlockIndex; enum class SynchronizationState; @@ -15,6 +17,8 @@ class KernelNotifications : public kernel::Notifications { public: void blockTip(SynchronizationState state, CBlockIndex& index) override; + + void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override; }; } // namespace node diff --git a/src/validation.cpp b/src/validation.cpp index 7762cf68d9a..21592709439 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3097,7 +3097,7 @@ static bool NotifyHeaderTip(Chainstate& chainstate) LOCKS_EXCLUDED(cs_main) { } // Send block tip changed notifications without cs_main if (fNotify) { - uiInterface.NotifyHeaderTip(GetSynchronizationState(fInitialBlockDownload), pindexHeader->nHeight, pindexHeader->nTime, false); + chainstate.m_chainman.GetNotifications().headerTip(GetSynchronizationState(fInitialBlockDownload), pindexHeader->nHeight, pindexHeader->nTime, false); } return fNotify; } @@ -3920,7 +3920,7 @@ void ChainstateManager::ReportHeadersPresync(const arith_uint256& work, int64_t m_last_presync_update = now; } bool initial_download = chainstate.IsInitialBlockDownload(); - uiInterface.NotifyHeaderTip(GetSynchronizationState(initial_download), height, timestamp, /*presync=*/true); + GetNotifications().headerTip(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)};