Bitcoin Core  27.99.0
P2P Digital Currency
notifications_interface.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_KERNEL_NOTIFICATIONS_INTERFACE_H
6 #define BITCOIN_KERNEL_NOTIFICATIONS_INTERFACE_H
7 
8 #include <cstdint>
9 #include <variant>
10 
11 class CBlockIndex;
12 enum class SynchronizationState;
13 struct bilingual_str;
14 
15 namespace kernel {
16 
18 struct Interrupted{};
19 
21 using InterruptResult = std::variant<std::monostate, Interrupted>;
22 
23 template <typename T>
24 bool IsInterrupted(const T& result)
25 {
26  return std::holds_alternative<kernel::Interrupted>(result);
27 }
28 
34 {
35 public:
36  virtual ~Notifications(){};
37 
38  [[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) { return {}; }
39  virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {}
40  virtual void progress(const bilingual_str& title, int progress_percent, bool resume_possible) {}
41  virtual void warning(const bilingual_str& warning) {}
42 
49  virtual void flushError(const bilingual_str& message) {}
50 
58  virtual void fatalError(const bilingual_str& message) {}
59 };
60 } // namespace kernel
61 
62 #endif // BITCOIN_KERNEL_NOTIFICATIONS_INTERFACE_H
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.
virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync)
virtual void fatalError(const bilingual_str &message)
The fatal error notification is sent to notify the user when an error occurs in kernel code that can'...
virtual void warning(const bilingual_str &warning)
virtual void progress(const bilingual_str &title, int progress_percent, bool resume_possible)
virtual void flushError(const bilingual_str &message)
The flush error notification is sent to notify the user that an error occurred while flushing block d...
virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex &index)
std::variant< std::monostate, Interrupted > InterruptResult
Simple result type for functions that need to propagate an interrupt status and don't have other retu...
bool IsInterrupted(const T &result)
Bilingual messages:
Definition: translation.h:18
Result type for use with std::variant to indicate that an operation should be interrupted.
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:80