0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

refactor: Make GetWarnings() bilingual_str aware internally

This commit is contained in:
Hennadii Stepanov 2020-06-10 11:21:40 +03:00
parent 20e9531379
commit 38e33aa481
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -6,9 +6,12 @@
#include <warnings.h>
#include <sync.h>
#include <util/string.h>
#include <util/system.h>
#include <util/translation.h>
#include <vector>
static Mutex g_warnings_mutex;
static std::string strMiscWarning GUARDED_BY(g_warnings_mutex);
static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false;
@ -40,32 +43,34 @@ void SetfLargeWorkInvalidChainFound(bool flag)
std::string GetWarnings(bool verbose)
{
std::string warnings_concise;
std::string warnings_verbose;
const std::string warning_separator = "<hr />";
bilingual_str warnings_concise;
std::vector<bilingual_str> warnings_verbose;
LOCK(g_warnings_mutex);
// Pre-release build warning
if (!CLIENT_VERSION_IS_RELEASE) {
warnings_concise = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
warnings_verbose = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications").translated;
warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
warnings_verbose.emplace_back(warnings_concise);
}
// Misc warnings like out of disk space and clock is wrong
if (strMiscWarning != "") {
warnings_concise = strMiscWarning;
warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + strMiscWarning;
if (!strMiscWarning.empty()) {
warnings_concise = Untranslated(strMiscWarning);
warnings_verbose.emplace_back(warnings_concise);
}
if (fLargeWorkForkFound) {
warnings_concise = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.").translated;
warnings_concise = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
warnings_verbose.emplace_back(warnings_concise);
} else if (fLargeWorkInvalidChainFound) {
warnings_concise = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.").translated;
warnings_concise = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
warnings_verbose.emplace_back(warnings_concise);
}
if (verbose) return warnings_verbose;
else return warnings_concise;
if (verbose) {
return Join(warnings_verbose, Untranslated("<hr />")).translated;
}
return warnings_concise.original;
}