Bitcoin Core 28.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
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
13class ArgsManager;
14class CBlockIndex;
15enum class SynchronizationState;
16struct bilingual_str;
17
18namespace kernel {
19enum class Warning;
20} // namespace kernel
21
22namespace util {
23class SignalInterrupt;
24} // namespace util
25
26namespace node {
27
28class Warnings;
29static constexpr int DEFAULT_STOPATHEIGHT{0};
30
32{
33public:
35 : m_shutdown(shutdown), m_exit_status{exit_status}, m_warnings{warnings} {}
36
37 [[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) override;
38
39 void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override;
40
41 void progress(const bilingual_str& title, int progress_percent, bool resume_possible) override;
42
43 void warningSet(kernel::Warning id, const bilingual_str& message) override;
44
45 void warningUnset(kernel::Warning id) override;
46
47 void flushError(const bilingual_str& message) override;
48
49 void fatalError(const bilingual_str& message) override;
50
52 int m_stop_at_height{DEFAULT_STOPATHEIGHT};
55private:
57 std::atomic<int>& m_exit_status;
59};
60
61void ReadNotificationArgs(const ArgsManager& args, KernelNotifications& notifications);
62
63} // namespace node
64
65#endif // BITCOIN_NODE_KERNEL_NOTIFICATIONS_H
int exit_status
ArgsManager & args
Definition bitcoind.cpp:270
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.
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 warningSet(kernel::Warning id, const bilingual_str &message) override
KernelNotifications(util::SignalInterrupt &shutdown, std::atomic< int > &exit_status, node::Warnings &warnings)
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'...
void warningUnset(kernel::Warning id) override
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...
Manages warning messages within a node.
Definition warnings.h:40
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
Warning
Definition warning.h:9
std::variant< std::monostate, Interrupted > InterruptResult
Simple result type for functions that need to propagate an interrupt status and don't have other retu...
void ReadNotificationArgs(const ArgsManager &args, KernelNotifications &notifications)
Bilingual messages:
Definition translation.h:18
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition validation.h:82