diff options
Diffstat (limited to 'src/node/kernel_notifications.cpp')
-rw-r--r-- | src/node/kernel_notifications.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/node/kernel_notifications.cpp b/src/node/kernel_notifications.cpp index 0be7d51afb..7224127c72 100644 --- a/src/node/kernel_notifications.cpp +++ b/src/node/kernel_notifications.cpp @@ -8,6 +8,7 @@ #include <config/bitcoin-config.h> #endif +#include <chain.h> #include <common/args.h> #include <common/system.h> #include <kernel/context.h> @@ -57,9 +58,14 @@ static void DoWarning(const bilingual_str& warning) namespace node { -void KernelNotifications::blockTip(SynchronizationState state, CBlockIndex& index) +kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state, CBlockIndex& index) { uiInterface.NotifyBlockTip(state, &index); + if (m_stop_at_height && index.nHeight >= m_stop_at_height) { + StartShutdown(); + return kernel::Interrupted{}; + } + return {}; } void KernelNotifications::headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) @@ -87,4 +93,9 @@ void KernelNotifications::fatalError(const std::string& debug_message, const bil node::AbortNode(m_exit_status, debug_message, user_message, m_shutdown_on_fatal_error); } +void ReadNotificationArgs(const ArgsManager& args, KernelNotifications& notifications) +{ + if (auto value{args.GetIntArg("-stopatheight")}) notifications.m_stop_at_height = *value; +} + } // namespace node |