refactor: Remove calls to StartShutdown from KernelNotifications

Use SignalInterrupt object instead. There is a slight change in behavior here
because the previous StartShutdown code used to abort on failure and the
new code logs errors instead.
This commit is contained in:
Ryan Ofsky
2023-07-07 17:32:54 -04:00
parent 6824eecaf1
commit feeb7b816a
9 changed files with 29 additions and 17 deletions

View File

@@ -15,7 +15,6 @@
#include <logging.h>
#include <node/abort.h>
#include <node/interface_ui.h>
#include <shutdown.h>
#include <util/check.h>
#include <util/strencodings.h>
#include <util/string.h>
@@ -62,7 +61,9 @@ kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state
{
uiInterface.NotifyBlockTip(state, &index);
if (m_stop_at_height && index.nHeight >= m_stop_at_height) {
StartShutdown();
if (!m_shutdown()) {
LogPrintf("Error: failed to send shutdown signal after reaching stop height\n");
}
return kernel::Interrupted{};
}
return {};
@@ -85,12 +86,13 @@ void KernelNotifications::warning(const bilingual_str& warning)
void KernelNotifications::flushError(const std::string& debug_message)
{
AbortNode(m_exit_status, debug_message);
AbortNode(&m_shutdown, m_exit_status, debug_message);
}
void KernelNotifications::fatalError(const std::string& debug_message, const bilingual_str& user_message)
{
node::AbortNode(m_exit_status, debug_message, user_message, m_shutdown_on_fatal_error);
node::AbortNode(m_shutdown_on_fatal_error ? &m_shutdown : nullptr,
m_exit_status, debug_message, user_message);
}
void ReadNotificationArgs(const ArgsManager& args, KernelNotifications& notifications)