aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoin-chainstate.cpp
diff options
context:
space:
mode:
authorstickies-v <stickies-v@protonmail.com>2024-05-07 17:05:40 +0100
committerstickies-v <stickies-v@protonmail.com>2024-06-13 11:20:48 +0100
commitb071ad9770b7ae7fc718dcbfdc8f62dffbf6cfee (patch)
tree71f6d60e4546b6567a840d1e7733cfd73c60b5fa /src/bitcoin-chainstate.cpp
parent20e616f86444d00712ac7eb840666e2b0378af4a (diff)
introduce and use the generalized `node::Warnings` interface
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.
Diffstat (limited to 'src/bitcoin-chainstate.cpp')
-rw-r--r--src/bitcoin-chainstate.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp
index ca4434a882..ecbdcd48bb 100644
--- a/src/bitcoin-chainstate.cpp
+++ b/src/bitcoin-chainstate.cpp
@@ -16,6 +16,7 @@
#include <kernel/checks.h>
#include <kernel/context.h>
#include <kernel/validation_cache_sizes.h>
+#include <kernel/warning.h>
#include <consensus/validation.h>
#include <core_io.h>
@@ -28,6 +29,7 @@
#include <util/fs.h>
#include <util/signalinterrupt.h>
#include <util/task_runner.h>
+#include <util/translation.h>
#include <validation.h>
#include <validationinterface.h>
@@ -86,9 +88,13 @@ int main(int argc, char* argv[])
{
std::cout << "Progress: " << title.original << ", " << progress_percent << ", " << resume_possible << std::endl;
}
- void warning(const bilingual_str& warning) override
+ void warningSet(kernel::Warning id, const bilingual_str& message) override
{
- std::cout << "Warning: " << warning.original << std::endl;
+ std::cout << "Warning " << static_cast<int>(id) << " set: " << message.original << std::endl;
+ }
+ void warningUnset(kernel::Warning id) override
+ {
+ std::cout << "Warning " << static_cast<int>(id) << " unset" << std::endl;
}
void flushError(const bilingual_str& message) override
{