2023-05-10 22:29:17 +02:00
|
|
|
// Copyright (c) 2023 The Bitcoin Core developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_NODE_KERNEL_NOTIFICATIONS_H
|
|
|
|
#define BITCOIN_NODE_KERNEL_NOTIFICATIONS_H
|
|
|
|
|
|
|
|
#include <kernel/notifications_interface.h>
|
|
|
|
|
2023-05-09 11:15:46 +02:00
|
|
|
#include <atomic>
|
2023-05-10 22:35:49 +02:00
|
|
|
#include <cstdint>
|
|
|
|
|
2023-07-07 12:53:31 -04:00
|
|
|
class ArgsManager;
|
2023-05-10 22:29:17 +02:00
|
|
|
class CBlockIndex;
|
|
|
|
enum class SynchronizationState;
|
2023-05-10 22:36:04 +02:00
|
|
|
struct bilingual_str;
|
2023-05-10 22:29:17 +02:00
|
|
|
|
2023-07-07 17:32:54 -04:00
|
|
|
namespace util {
|
|
|
|
class SignalInterrupt;
|
|
|
|
} // namespace util
|
|
|
|
|
2023-05-10 22:29:17 +02:00
|
|
|
namespace node {
|
2023-07-07 12:53:31 -04:00
|
|
|
|
|
|
|
static constexpr int DEFAULT_STOPATHEIGHT{0};
|
|
|
|
|
2023-05-10 22:29:17 +02:00
|
|
|
class KernelNotifications : public kernel::Notifications
|
|
|
|
{
|
|
|
|
public:
|
2023-07-07 17:32:54 -04:00
|
|
|
KernelNotifications(util::SignalInterrupt& shutdown, std::atomic<int>& exit_status) : m_shutdown(shutdown), m_exit_status{exit_status} {}
|
2023-05-09 11:15:46 +02:00
|
|
|
|
2023-07-07 12:53:31 -04:00
|
|
|
[[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) override;
|
2023-05-10 22:35:49 +02:00
|
|
|
|
|
|
|
void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override;
|
2023-05-10 22:36:04 +02:00
|
|
|
|
|
|
|
void progress(const bilingual_str& title, int progress_percent, bool resume_possible) override;
|
2023-05-08 14:49:37 +02:00
|
|
|
|
|
|
|
void warning(const bilingual_str& warning) override;
|
2023-06-15 23:09:37 +02:00
|
|
|
|
2024-03-15 21:42:44 +01:00
|
|
|
void flushError(const bilingual_str& message) override;
|
2023-05-09 11:15:46 +02:00
|
|
|
|
2024-03-15 21:42:44 +01:00
|
|
|
void fatalError(const bilingual_str& message) override;
|
2023-05-09 11:15:46 +02:00
|
|
|
|
2023-07-07 12:53:31 -04:00
|
|
|
//! Block height after which blockTip notification will return Interrupted{}, if >0.
|
|
|
|
int m_stop_at_height{DEFAULT_STOPATHEIGHT};
|
2023-05-09 11:15:46 +02:00
|
|
|
//! Useful for tests, can be set to false to avoid shutdown on fatal error.
|
|
|
|
bool m_shutdown_on_fatal_error{true};
|
|
|
|
private:
|
2023-07-07 17:32:54 -04:00
|
|
|
util::SignalInterrupt& m_shutdown;
|
2023-05-09 11:15:46 +02:00
|
|
|
std::atomic<int>& m_exit_status;
|
2023-05-10 22:29:17 +02:00
|
|
|
};
|
2023-07-07 12:53:31 -04:00
|
|
|
|
|
|
|
void ReadNotificationArgs(const ArgsManager& args, KernelNotifications& notifications);
|
|
|
|
|
2023-05-10 22:29:17 +02:00
|
|
|
} // namespace node
|
|
|
|
|
|
|
|
#endif // BITCOIN_NODE_KERNEL_NOTIFICATIONS_H
|