mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
Instead of having separate warning functions (and globals) for each different warning that can be raised, encapsulate this logic into a single class and allow to (un)set any number of warnings. Introduces behaviour change: - the `-alertnotify` command is executed for all `KernelNotifications::warningSet` calls, which now also covers the `LARGE_WORK_INVALID_CHAIN` warning. - previously, warnings were returned based on a predetermined order, e.g. with the "pre-release test build" warning always first. This is no longer the case, and Warnings::GetMessages() will return messages sorted by the id of the warning. Removes warnings.cpp from kernel.
28 lines
836 B
C++
28 lines
836 B
C++
// 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.
|
|
|
|
#include <node/abort.h>
|
|
|
|
#include <logging.h>
|
|
#include <node/interface_ui.h>
|
|
#include <node/warnings.h>
|
|
#include <util/signalinterrupt.h>
|
|
#include <util/translation.h>
|
|
|
|
#include <atomic>
|
|
#include <cstdlib>
|
|
|
|
namespace node {
|
|
|
|
void AbortNode(util::SignalInterrupt* shutdown, std::atomic<int>& exit_status, const bilingual_str& message)
|
|
{
|
|
g_warnings.Set(Warning::FATAL_INTERNAL_ERROR, message);
|
|
InitError(_("A fatal internal error occurred, see debug.log for details: ") + message);
|
|
exit_status.store(EXIT_FAILURE);
|
|
if (shutdown && !(*shutdown)()) {
|
|
LogError("Failed to send shutdown signal\n");
|
|
};
|
|
}
|
|
} // namespace node
|