aboutsummaryrefslogtreecommitdiff
path: root/src/node/kernel_notifications.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/node/kernel_notifications.h')
-rw-r--r--src/node/kernel_notifications.h25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/node/kernel_notifications.h b/src/node/kernel_notifications.h
index e37f4d4e1e..296b9c426d 100644
--- a/src/node/kernel_notifications.h
+++ b/src/node/kernel_notifications.h
@@ -7,8 +7,13 @@
#include <kernel/notifications_interface.h>
+#include <sync.h>
+#include <threadsafety.h>
+#include <uint256.h>
+
#include <atomic>
#include <cstdint>
+#include <functional>
class ArgsManager;
class CBlockIndex;
@@ -19,10 +24,6 @@ namespace kernel {
enum class Warning;
} // namespace kernel
-namespace util {
-class SignalInterrupt;
-} // namespace util
-
namespace node {
class Warnings;
@@ -31,10 +32,10 @@ static constexpr int DEFAULT_STOPATHEIGHT{0};
class KernelNotifications : public kernel::Notifications
{
public:
- KernelNotifications(util::SignalInterrupt& shutdown, std::atomic<int>& exit_status, node::Warnings& warnings)
- : m_shutdown(shutdown), m_exit_status{exit_status}, m_warnings{warnings} {}
+ KernelNotifications(const std::function<bool()>& shutdown_request, std::atomic<int>& exit_status, node::Warnings& warnings)
+ : m_shutdown_request(shutdown_request), m_exit_status{exit_status}, m_warnings{warnings} {}
- [[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) override;
+ [[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) override EXCLUSIVE_LOCKS_REQUIRED(!m_tip_block_mutex);
void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override;
@@ -52,8 +53,16 @@ public:
int m_stop_at_height{DEFAULT_STOPATHEIGHT};
//! Useful for tests, can be set to false to avoid shutdown on fatal error.
bool m_shutdown_on_fatal_error{true};
+
+ Mutex m_tip_block_mutex;
+ std::condition_variable m_tip_block_cv GUARDED_BY(m_tip_block_mutex);
+ //! The block for which the last blockTip notification was received for.
+ //! The initial ZERO means that no block has been connected yet, which may
+ //! be true even long after startup, until shutdown.
+ uint256 m_tip_block GUARDED_BY(m_tip_block_mutex){uint256::ZERO};
+
private:
- util::SignalInterrupt& m_shutdown;
+ const std::function<bool()>& m_shutdown_request;
std::atomic<int>& m_exit_status;
node::Warnings& m_warnings;
};