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 : #include <hash.h> 13 : 14 : #include <vector> 15 : 16 : static GlobalMutex g_warnings_mutex; 17 : static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex); 18 : static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false; 19 : 20 1790 : void SetMiscWarning(const bilingual_str& warning) 21 : { 22 1790 : LOCK(g_warnings_mutex); 23 1790 : g_misc_warnings = warning; 24 1790 : } 25 : 26 229884 : void SetfLargeWorkInvalidChainFound(bool flag) 27 : { 28 229884 : LOCK(g_warnings_mutex); 29 229884 : fLargeWorkInvalidChainFound = flag; 30 229884 : } 31 : 32 19348 : bilingual_str GetWarnings(bool verbose) 33 : { 34 19348 : bilingual_str warnings_concise; 35 19348 : std::vector<bilingual_str> warnings_verbose; 36 : 37 19348 : LOCK(g_warnings_mutex); 38 : 39 : // Pre-release build warning 40 : if (!CLIENT_VERSION_IS_RELEASE) { 41 19348 : warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"); 42 19348 : warnings_verbose.emplace_back(warnings_concise); 43 : } 44 : 45 : // Misc warnings like out of disk space and clock is wrong 46 19348 : if (!g_misc_warnings.empty()) { 47 3185 : warnings_concise = g_misc_warnings; 48 3185 : warnings_verbose.emplace_back(warnings_concise); 49 3185 : } 50 : 51 19348 : if (fLargeWorkInvalidChainFound) { 52 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."); 53 0 : warnings_verbose.emplace_back(warnings_concise); 54 0 : } 55 : 56 19348 : if (verbose) { 57 1 : return Join(warnings_verbose, Untranslated("<hr />")); 58 : } 59 : 60 19347 : return warnings_concise; 61 19348 : }