Bitcoin Core  27.99.0
P2P Digital Currency
kernel_notifications.h
Go to the documentation of this file.
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 
9 
10 #include <atomic>
11 #include <cstdint>
12 
13 class ArgsManager;
14 class CBlockIndex;
15 enum class SynchronizationState;
16 struct bilingual_str;
17 
18 namespace util {
19 class SignalInterrupt;
20 } // namespace util
21 
22 namespace node {
23 
24 static constexpr int DEFAULT_STOPATHEIGHT{0};
25 
27 {
28 public:
30 
31  [[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) override;
32 
33  void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override;
34 
35  void progress(const bilingual_str& title, int progress_percent, bool resume_possible) override;
36 
37  void warning(const bilingual_str& warning) override;
38 
39  void flushError(const bilingual_str& message) override;
40 
41  void fatalError(const bilingual_str& message) override;
42 
47 private:
49  std::atomic<int>& m_exit_status;
50 };
51 
52 void ReadNotificationArgs(const ArgsManager& args, KernelNotifications& notifications);
53 
54 } // namespace node
55 
56 #endif // BITCOIN_NODE_KERNEL_NOTIFICATIONS_H
int exit_status
ArgsManager & args
Definition: bitcoind.cpp:268
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:141
A base class defining functions for notifying about certain kernel events.
util::SignalInterrupt & m_shutdown
int m_stop_at_height
Block height after which blockTip notification will return Interrupted{}, if >0.
KernelNotifications(util::SignalInterrupt &shutdown, std::atomic< int > &exit_status)
void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override
std::atomic< int > & m_exit_status
void progress(const bilingual_str &title, int progress_percent, bool resume_possible) override
void warning(const bilingual_str &warning) override
void fatalError(const bilingual_str &message) override
The fatal error notification is sent to notify the user when an error occurs in kernel code that can'...
kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex &index) override
bool m_shutdown_on_fatal_error
Useful for tests, can be set to false to avoid shutdown on fatal error.
void flushError(const bilingual_str &message) override
The flush error notification is sent to notify the user that an error occurred while flushing block d...
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
std::variant< std::monostate, Interrupted > InterruptResult
Simple result type for functions that need to propagate an interrupt status and don't have other retu...
Definition: init.h:25
void ReadNotificationArgs(const ArgsManager &args, KernelNotifications &notifications)
static constexpr int DEFAULT_STOPATHEIGHT
Bilingual messages:
Definition: translation.h:18
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:80