Merge 371a73e940 into merged_master (Bitcoin PR #19233)

This commit is contained in:
Andrew Poelstra 2020-11-26 01:09:02 +00:00
commit 440e85cbdb
13 changed files with 57 additions and 45 deletions

View file

@ -1759,7 +1759,7 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
// TODO: AbortNode() should take bilingual_str userMessage parameter.
static bool AbortNode(const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
{
SetMiscWarning(strMessage);
SetMiscWarning(Untranslated(strMessage));
LogPrintf("*** %s\n", strMessage);
if (!userMessage.empty()) {
uiInterface.ThreadSafeMessageBox(Untranslated(userMessage), "", CClientUIInterface::MSG_ERROR | prefix);
@ -2610,20 +2610,20 @@ void CChainState::PruneAndFlush() {
}
}
static void DoWarning(const std::string& strWarning)
static void DoWarning(const bilingual_str& warning)
{
static bool fWarned = false;
SetMiscWarning(strWarning);
SetMiscWarning(warning);
if (!fWarned) {
AlertNotify(strWarning);
AlertNotify(warning.original);
fWarned = true;
}
}
/** Private helper function that concatenates warning messages. */
static void AppendWarning(std::string& res, const std::string& warn)
static void AppendWarning(bilingual_str& res, const bilingual_str& warn)
{
if (!res.empty()) res += ", ";
if (!res.empty()) res += Untranslated(", ");
res += warn;
}
@ -2640,7 +2640,7 @@ void static UpdateTip(const CBlockIndex* pindexNew, const CChainParams& chainPar
g_best_block_cv.notify_all();
}
std::string warningMessages;
bilingual_str warning_messages;
if (!::ChainstateActive().IsInitialBlockDownload())
{
int nUpgraded = 0;
@ -2649,11 +2649,11 @@ void static UpdateTip(const CBlockIndex* pindexNew, const CChainParams& chainPar
WarningBitsConditionChecker checker(bit);
ThresholdState state = checker.GetStateFor(pindex, chainParams.GetConsensus(), warningcache[bit]);
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
const std::string strWarning = strprintf(_("Warning: unknown new rules activated (versionbit %i)").translated, bit);
const bilingual_str warning = strprintf(_("Warning: unknown new rules activated (versionbit %i)"), bit);
if (state == ThresholdState::ACTIVE) {
DoWarning(strWarning);
DoWarning(warning);
} else {
AppendWarning(warningMessages, strWarning);
AppendWarning(warning_messages, warning);
}
}
}
@ -2666,7 +2666,7 @@ void static UpdateTip(const CBlockIndex* pindexNew, const CChainParams& chainPar
pindex = pindex->pprev;
}
if (nUpgraded > 0)
AppendWarning(warningMessages, strprintf(_("%d of last 100 blocks have unexpected version").translated, nUpgraded));
AppendWarning(warning_messages, strprintf(_("%d of last 100 blocks have unexpected version"), nUpgraded));
}
LogPrintf("%s: new best=%s height=%d version=0x%08x tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)%s\n", __func__,
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, pindexNew->nVersion,
@ -2674,7 +2674,7 @@ void static UpdateTip(const CBlockIndex* pindexNew, const CChainParams& chainPar
FormatISO8601DateTime(pindexNew->GetBlockTime()),
GuessVerificationProgress(pindexNew, chainParams.GetConsensus().nPowTargetSpacing),
::ChainstateActive().CoinsTip().DynamicMemoryUsage() * (1.0 / (1<<20)), ::ChainstateActive().CoinsTip().GetCacheSize(),
!warningMessages.empty() ? strprintf(" warning='%s'", warningMessages) : "");
!warning_messages.empty() ? strprintf(" warning='%s'", warning_messages.original) : "");
}