Line data Source code
1 : // Copyright (c) 2023 The Bitcoin Core developers 2 : // Distributed under the MIT software license, see the accompanying 3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 : 5 : #ifndef BITCOIN_NODE_KERNEL_NOTIFICATIONS_H 6 : #define BITCOIN_NODE_KERNEL_NOTIFICATIONS_H 7 : 8 : #include <kernel/notifications_interface.h> 9 : 10 : #include <atomic> 11 : #include <cstdint> 12 : #include <string> 13 : 14 : class ArgsManager; 15 : class CBlockIndex; 16 : enum class SynchronizationState; 17 : struct bilingual_str; 18 : 19 : namespace node { 20 : 21 : static constexpr int DEFAULT_STOPATHEIGHT{0}; 22 : 23 : class KernelNotifications : public kernel::Notifications 24 : { 25 : public: 26 2 : KernelNotifications(std::atomic<int>& exit_status) : m_exit_status{exit_status} {} 27 : 28 : [[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) override; 29 : 30 : void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override; 31 : 32 : void progress(const bilingual_str& title, int progress_percent, bool resume_possible) override; 33 : 34 : void warning(const bilingual_str& warning) override; 35 : 36 : void flushError(const std::string& debug_message) override; 37 : 38 : void fatalError(const std::string& debug_message, const bilingual_str& user_message = {}) override; 39 : 40 : //! Block height after which blockTip notification will return Interrupted{}, if >0. 41 1 : int m_stop_at_height{DEFAULT_STOPATHEIGHT}; 42 : //! Useful for tests, can be set to false to avoid shutdown on fatal error. 43 1 : bool m_shutdown_on_fatal_error{true}; 44 : private: 45 : std::atomic<int>& m_exit_status; 46 : }; 47 : 48 : void ReadNotificationArgs(const ArgsManager& args, KernelNotifications& notifications); 49 : 50 : } // namespace node 51 : 52 : #endif // BITCOIN_NODE_KERNEL_NOTIFICATIONS_H