Refactor block warning messages to display multiple

This commit is contained in:
Luke Dashjr 2024-01-05 20:30:17 +00:00
parent 4f5f6c755a
commit 50944ca9a7

View File

@ -2746,12 +2746,9 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
ThresholdState state = checker.GetStateFor(pindex, params.GetConsensus(), m_chainman.m_warningcache.at(bit)); ThresholdState state = checker.GetStateFor(pindex, params.GetConsensus(), m_chainman.m_warningcache.at(bit));
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) { if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit); const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
{
m_chainman.GetNotifications().warning(warning);
AppendWarning(warning_messages, warning); AppendWarning(warning_messages, warning);
} }
} }
}
// Check the version of the last 100 blocks to see if we need to upgrade: // Check the version of the last 100 blocks to see if we need to upgrade:
int unexpected_bit_count[VERSIONBITS_NUM_BITS], nonversionbit_count = 0; int unexpected_bit_count[VERSIONBITS_NUM_BITS], nonversionbit_count = 0;
@ -2782,13 +2779,14 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
pindex = pindex->pprev; pindex = pindex->pprev;
} }
if (warning_threshold_hit) { if (warning_threshold_hit) {
auto strWarning = _("Warning: Unrecognised block version being mined! Unknown rules may or may not be in effect"); const auto warning = _("Warning: Unrecognised block version being mined! Unknown rules may or may not be in effect");
// notify GetWarnings(), called by Qt and the JSON-RPC code to warn the user: AppendWarning(warning_messages, warning);
m_chainman.GetNotifications().warning(strWarning);
AppendWarning(warning_messages, strWarning);
} }
} }
UpdateTipLog(coins_tip, pindexNew, params, __func__, "", warning_messages.original); UpdateTipLog(coins_tip, pindexNew, params, __func__, "", warning_messages.original);
if (!warning_messages.empty()) {
m_chainman.GetNotifications().warning(warning_messages);
}
} }
/** Disconnect m_chain's tip. /** Disconnect m_chain's tip.