Bitcoin Core  27.99.0
P2P Digital Currency
warnings.cpp
Go to the documentation of this file.
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)
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 
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 {
26  g_misc_warnings = warning;
27 }
28 
30 {
32  fLargeWorkInvalidChainFound = flag;
33 }
34 
36 {
37  bilingual_str warnings_concise;
38  std::vector<bilingual_str> warnings_verbose;
39 
41 
42  // Pre-release build warning
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 }
#define CLIENT_VERSION_IS_RELEASE
Different type to mark Mutex at global scope.
Definition: sync.h:140
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
Definition: string.h:68
Bilingual messages:
Definition: translation.h:18
#define LOCK(cs)
Definition: sync.h:257
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:74
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:48
bilingual_str GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.
Definition: warnings.cpp:35
void SetfLargeWorkInvalidChainFound(bool flag)
Definition: warnings.cpp:29
static GlobalMutex g_warnings_mutex
Definition: warnings.cpp:19
void SetMiscWarning(const bilingual_str &warning)
Definition: warnings.cpp:23
static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex)