Branch data Line data Source code
# 1 : : // Copyright (c) 2009-2010 Satoshi Nakamoto # 2 : : // Copyright (c) 2009-2020 The Bitcoin Core developers # 3 : : // Distributed under the MIT software license, see the accompanying # 4 : : // file COPYING or http://www.opensource.org/licenses/mit-license.php. # 5 : : # 6 : : #include <warnings.h> # 7 : : # 8 : : #include <sync.h> # 9 : : #include <util/string.h> # 10 : : #include <util/system.h> # 11 : : #include <util/translation.h> # 12 : : # 13 : : #include <vector> # 14 : : # 15 : : static Mutex g_warnings_mutex; # 16 : : static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex); # 17 : : static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false; # 18 : : # 19 : : void SetMiscWarning(const bilingual_str& warning) # 20 : 7 : { # 21 : 7 : LOCK(g_warnings_mutex); # 22 : 7 : g_misc_warnings = warning; # 23 : 7 : } # 24 : : # 25 : : void SetfLargeWorkInvalidChainFound(bool flag) # 26 : 65561 : { # 27 : 65561 : LOCK(g_warnings_mutex); # 28 : 65561 : fLargeWorkInvalidChainFound = flag; # 29 : 65561 : } # 30 : : # 31 : : bilingual_str GetWarnings(bool verbose) # 32 : 527 : { # 33 : 527 : bilingual_str warnings_concise; # 34 : 527 : std::vector<bilingual_str> warnings_verbose; # 35 : : # 36 : 527 : LOCK(g_warnings_mutex); # 37 : : # 38 : : // Pre-release build warning # 39 : 527 : if (!CLIENT_VERSION_IS_RELEASE) { # 40 : 527 : warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"); # 41 : 527 : warnings_verbose.emplace_back(warnings_concise); # 42 : 527 : } # 43 : : # 44 : : // Misc warnings like out of disk space and clock is wrong # 45 [ + + ]: 527 : if (!g_misc_warnings.empty()) { # 46 : 5 : warnings_concise = g_misc_warnings; # 47 : 5 : warnings_verbose.emplace_back(warnings_concise); # 48 : 5 : } # 49 : : # 50 [ - + ]: 527 : if (fLargeWorkInvalidChainFound) { # 51 : 0 : 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."); # 52 : 0 : warnings_verbose.emplace_back(warnings_concise); # 53 : 0 : } # 54 : : # 55 [ + + ]: 527 : if (verbose) { # 56 : 2 : return Join(warnings_verbose, Untranslated("<hr />")); # 57 : 2 : } # 58 : : # 59 : 525 : return warnings_concise; # 60 : 527 : }