mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-10 15:47:17 +02:00
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.
This commit is contained in:
@@ -27,11 +27,11 @@
|
||||
#include <kernel/mempool_entry.h>
|
||||
#include <kernel/messagestartchars.h>
|
||||
#include <kernel/notifications_interface.h>
|
||||
#include <kernel/warning.h>
|
||||
#include <logging.h>
|
||||
#include <logging/timer.h>
|
||||
#include <node/blockstorage.h>
|
||||
#include <node/utxo_snapshot.h>
|
||||
#include <node/warnings.h>
|
||||
#include <policy/policy.h>
|
||||
#include <policy/rbf.h>
|
||||
#include <policy/settings.h>
|
||||
@@ -1922,9 +1922,11 @@ void Chainstate::CheckForkWarningConditions()
|
||||
|
||||
if (m_chainman.m_best_invalid && m_chainman.m_best_invalid->nChainWork > m_chain.Tip()->nChainWork + (GetBlockProof(*m_chain.Tip()) * 6)) {
|
||||
LogPrintf("%s: Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.\n", __func__);
|
||||
node::SetfLargeWorkInvalidChainFound(true);
|
||||
m_chainman.GetNotifications().warningSet(
|
||||
kernel::Warning::LARGE_WORK_INVALID_CHAIN,
|
||||
_("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade."));
|
||||
} else {
|
||||
node::SetfLargeWorkInvalidChainFound(false);
|
||||
m_chainman.GetNotifications().warningUnset(kernel::Warning::LARGE_WORK_INVALID_CHAIN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2907,7 +2909,7 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
|
||||
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
|
||||
const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
|
||||
if (state == ThresholdState::ACTIVE) {
|
||||
m_chainman.GetNotifications().warning(warning);
|
||||
m_chainman.GetNotifications().warningSet(kernel::Warning::UNKNOWN_NEW_RULES_ACTIVATED, warning);
|
||||
} else {
|
||||
warning_messages.push_back(warning);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user