diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-06-10 12:14:32 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-06-10 15:01:20 +0300 |
commit | d49612f98add29066817b7c808b76c2d728948e5 (patch) | |
tree | 63b71a0f69b6c829b177ffd4de5d8352b1b462e3 | |
parent | d1ae7c0355662481a7d181a0a458284936d53eb1 (diff) | |
download | bitcoin-d49612f98add29066817b7c808b76c2d728948e5.tar.xz |
Make SetMiscWarning() accept bilingual_str argument
-rw-r--r-- | src/index/base.cpp | 2 | ||||
-rw-r--r-- | src/timedata.cpp | 2 | ||||
-rw-r--r-- | src/validation.cpp | 24 | ||||
-rw-r--r-- | src/warnings.cpp | 10 | ||||
-rw-r--r-- | src/warnings.h | 2 |
5 files changed, 20 insertions, 20 deletions
diff --git a/src/index/base.cpp b/src/index/base.cpp index 74ea421e13..1d09f2e577 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -21,7 +21,7 @@ template<typename... Args> static void FatalError(const char* fmt, const Args&... args) { std::string strMessage = tfm::format(fmt, args...); - SetMiscWarning(strMessage); + SetMiscWarning(Untranslated(strMessage)); LogPrintf("*** %s\n", strMessage); uiInterface.ThreadSafeMessageBox( Untranslated("Error: A fatal internal error occurred, see debug.log for details"), diff --git a/src/timedata.cpp b/src/timedata.cpp index c67a3c96e8..16dac24a48 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -95,7 +95,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) if (!fMatch) { fDone = true; bilingual_str strMessage = strprintf(_("Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly."), PACKAGE_NAME); - SetMiscWarning(strMessage.translated); + SetMiscWarning(strMessage); uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); } } diff --git a/src/validation.cpp b/src/validation.cpp index 51d29dd869..cbe89443b8 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1666,7 +1666,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); @@ -2429,20 +2429,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; } @@ -2459,7 +2459,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; @@ -2468,11 +2468,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); } } } @@ -2485,14 +2485,14 @@ 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 log2_work=%.8g tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)%s\n", __func__, pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, pindexNew->nVersion, log(pindexNew->nChainWork.getdouble())/log(2.0), (unsigned long)pindexNew->nChainTx, FormatISO8601DateTime(pindexNew->GetBlockTime()), GuessVerificationProgress(chainParams.TxData(), pindexNew), ::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) : ""); } diff --git a/src/warnings.cpp b/src/warnings.cpp index 1dd7f63575..501bf7e637 100644 --- a/src/warnings.cpp +++ b/src/warnings.cpp @@ -13,14 +13,14 @@ #include <vector> static Mutex g_warnings_mutex; -static std::string strMiscWarning GUARDED_BY(g_warnings_mutex); +static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex); static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false; static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false; -void SetMiscWarning(const std::string& strWarning) +void SetMiscWarning(const bilingual_str& warning) { LOCK(g_warnings_mutex); - strMiscWarning = strWarning; + g_misc_warnings = warning; } void SetfLargeWorkForkFound(bool flag) @@ -55,8 +55,8 @@ bilingual_str GetWarnings(bool verbose) } // Misc warnings like out of disk space and clock is wrong - if (!strMiscWarning.empty()) { - warnings_concise = Untranslated(strMiscWarning); + if (!g_misc_warnings.empty()) { + warnings_concise = g_misc_warnings; warnings_verbose.emplace_back(warnings_concise); } diff --git a/src/warnings.h b/src/warnings.h index 8897ace9eb..28546eb753 100644 --- a/src/warnings.h +++ b/src/warnings.h @@ -10,7 +10,7 @@ struct bilingual_str; -void SetMiscWarning(const std::string& strWarning); +void SetMiscWarning(const bilingual_str& warning); void SetfLargeWorkForkFound(bool flag); bool GetfLargeWorkForkFound(); void SetfLargeWorkInvalidChainFound(bool flag); |