Bitcoin ABC 0.33.10
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 <util/translation.h>
9
10#include <cstdint>
11#include <string>
12#include <variant>
13
14class CBlockIndex;
15enum class SynchronizationState;
16
17namespace kernel {
18
21struct Interrupted {};
22
25using InterruptResult = std::variant<std::monostate, Interrupted>;
26
27template <typename T> bool IsInterrupted(const T &result) {
28 return std::holds_alternative<kernel::Interrupted>(result);
29}
30
36public:
37 virtual ~Notifications(){};
38
39 [[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state,
40 CBlockIndex &index) {
41 return {};
42 }
43 virtual void headerTip(SynchronizationState state, int64_t height,
44 int64_t timestamp, bool presync) {}
45 virtual void progress(const bilingual_str &title, int progress_percent,
46 bool resume_possible) {}
47 virtual void warning(const std::string &warning) {}
48
55 virtual void flushError(const std::string &debug_message) {}
56
64 virtual void fatalError(const std::string &debug_message,
65 const bilingual_str &user_message = {}) {}
66};
67} // namespace kernel
68
69#endif // BITCOIN_KERNEL_NOTIFICATIONS_INTERFACE_H
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:25
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 flushError(const std::string &debug_message)
The flush error notification is sent to notify the user that an error occurred while flushing block d...
virtual void fatalError(const std::string &debug_message, const bilingual_str &user_message={})
The fatal error notification is sent to notify the user when an error occurs in kernel code that can'...
virtual void warning(const std::string &warning)
virtual void progress(const bilingual_str &title, int progress_percent, bool resume_possible)
virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex &index)
Definition: init.h:28
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:17
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:110