Bitcoin Core  22.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-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 
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 {
22  g_misc_warnings = warning;
23 }
24 
26 {
28  fLargeWorkInvalidChainFound = flag;
29 }
30 
32 {
33  bilingual_str warnings_concise;
34  std::vector<bilingual_str> warnings_verbose;
35 
37 
38  // Pre-release build warning
40  warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
41  warnings_verbose.emplace_back(warnings_concise);
42  }
43 
44  // Misc warnings like out of disk space and clock is wrong
45  if (!g_misc_warnings.empty()) {
46  warnings_concise = g_misc_warnings;
47  warnings_verbose.emplace_back(warnings_concise);
48  }
49 
50  if (fLargeWorkInvalidChainFound) {
51  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  warnings_verbose.emplace_back(warnings_concise);
53  }
54 
55  if (verbose) {
56  return Join(warnings_verbose, Untranslated("<hr />"));
57  }
58 
59  return warnings_concise;
60 }
_
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:63
GUARDED_BY
static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex)
GetWarnings
bilingual_str GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.
Definition: warnings.cpp:31
sync.h
CLIENT_VERSION_IS_RELEASE
#define CLIENT_VERSION_IS_RELEASE
Definition: bitcoin-config.h:18
string.h
bilingual_str
Bilingual messages:
Definition: translation.h:16
AnnotatedMixin< std::mutex >
Untranslated
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:46
g_warnings_mutex
static Mutex g_warnings_mutex
Definition: warnings.cpp:15
SetMiscWarning
void SetMiscWarning(const bilingual_str &warning)
Definition: warnings.cpp:19
system.h
Join
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
Definition: string.h:44
translation.h
LOCK
#define LOCK(cs)
Definition: sync.h:226
SetfLargeWorkInvalidChainFound
void SetfLargeWorkInvalidChainFound(bool flag)
Definition: warnings.cpp:25
warnings.h