warnings.cpp
1 // Copyright (c) 2009-2010 Satoshi Nakamoto 2 // Copyright (c) 2009-2022 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 #if defined(HAVE_CONFIG_H) 7 #include <config/bitcoin-config.h> 8 #endif 9 10 #include <warnings.h> 11 12 #include <common/system.h> 13 #include <sync.h> 14 #include <util/string.h> 15 #include <util/translation.h> 16 17 #include <vector> 18 19 static GlobalMutex g_warnings_mutex; 20 static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex); 21 static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false; 22 23 void SetMiscWarning(const bilingual_str& warning) 24 { 25 LOCK(g_warnings_mutex); 26 g_misc_warnings = warning; 27 } 28 29 void SetfLargeWorkInvalidChainFound(bool flag) 30 { 31 LOCK(g_warnings_mutex); 32 fLargeWorkInvalidChainFound = flag; 33 } 34 35 bilingual_str GetWarnings(bool verbose) 36 { 37 bilingual_str warnings_concise; 38 std::vector<bilingual_str> warnings_verbose; 39 40 LOCK(g_warnings_mutex); 41 42 // Pre-release build warning 43 if (!CLIENT_VERSION_IS_RELEASE) { 44 warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"); 45 warnings_verbose.emplace_back(warnings_concise); 46 } 47 48 // Misc warnings like out of disk space and clock is wrong 49 if (!g_misc_warnings.empty()) { 50 warnings_concise = g_misc_warnings; 51 warnings_verbose.emplace_back(warnings_concise); 52 } 53 54 if (fLargeWorkInvalidChainFound) { 55 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."); 56 warnings_verbose.emplace_back(warnings_concise); 57 } 58 59 if (verbose) { 60 return Join(warnings_verbose, Untranslated("<hr />")); 61 } 62 63 return warnings_concise; 64 }