Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2023-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_KERNEL_NOTIFICATIONS_INTERFACE_H6#define BITCOIN_KERNEL_NOTIFICATIONS_INTERFACE_H8#include <cstdint>9#include <variant>11class CBlockIndex;12enum class SynchronizationState;13struct bilingual_str;15namespace kernel {17//! Result type for use with std::variant to indicate that an operation should be interrupted.18struct Interrupted{};19enum class Warning;22//! Simple result type for functions that need to propagate an interrupt status and don't have other return values.23using InterruptResult = std::variant<std::monostate, Interrupted>;25template <typename T>26bool IsInterrupted(const T& result)27{28return std::holds_alternative<kernel::Interrupted>(result);29}31/**32* A base class defining functions for notifying about certain kernel33* events.34*/35class Notifications36{37public:38virtual ~Notifications() = default;40[[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, const CBlockIndex& index, double verification_progress) { return {}; }41virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {}42virtual void progress(const bilingual_str& title, int progress_percent, bool resume_possible) {}43virtual void warningSet(Warning id, const bilingual_str& message) {}44virtual void warningUnset(Warning id) {}46//! The flush error notification is sent to notify the user that an error47//! occurred while flushing block data to disk. Kernel code may ignore flush48//! errors that don't affect the immediate operation it is trying to49//! perform. Applications can choose to handle the flush error notification50//! by logging the error, or notifying the user, or triggering an early51//! shutdown as a precaution against causing more errors.52virtual void flushError(const bilingual_str& message) {}54//! The fatal error notification is sent to notify the user when an error55//! occurs in kernel code that can't be recovered from. After this56//! notification is sent, whatever function triggered the error should also57//! return an error code or raise an exception. Applications can choose to58//! handle the fatal error notification by logging the error, or notifying59//! the user, or triggering an early shutdown as a precaution against60//! causing more errors.61virtual void fatalError(const bilingual_str& message) {}62};63} // namespace kernel65#endif // BITCOIN_KERNEL_NOTIFICATIONS_INTERFACE_H