diff options
Diffstat (limited to 'src/kernel/notifications_interface.h')
-rw-r--r-- | src/kernel/notifications_interface.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/kernel/notifications_interface.h b/src/kernel/notifications_interface.h index e596a144a8..c5e77b0df9 100644 --- a/src/kernel/notifications_interface.h +++ b/src/kernel/notifications_interface.h @@ -9,12 +9,25 @@ #include <cstdint> #include <string> +#include <variant> class CBlockIndex; enum class SynchronizationState; namespace kernel { +//! Result type for use with std::variant to indicate that an operation should be interrupted. +struct Interrupted{}; + +//! Simple result type for functions that need to propagate an interrupt status and don't have other return values. +using InterruptResult = std::variant<std::monostate, Interrupted>; + +template <typename T> +bool IsInterrupted(const T& result) +{ + return std::holds_alternative<kernel::Interrupted>(result); +} + /** * A base class defining functions for notifying about certain kernel * events. @@ -24,7 +37,7 @@ class Notifications public: virtual ~Notifications(){}; - virtual void blockTip(SynchronizationState state, CBlockIndex& index) {} + [[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) { return {}; } virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {} virtual void progress(const bilingual_str& title, int progress_percent, bool resume_possible) {} virtual void warning(const bilingual_str& warning) {} |