Bitcoin Core  0.19.99
P2P Digital Currency
warnings.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2019 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/system.h>
10 #include <util/translation.h>
11 
13 static std::string strMiscWarning GUARDED_BY(cs_warnings);
14 static bool fLargeWorkForkFound GUARDED_BY(cs_warnings) = false;
15 static bool fLargeWorkInvalidChainFound GUARDED_BY(cs_warnings) = false;
16 
17 void SetMiscWarning(const std::string& strWarning)
18 {
19  LOCK(cs_warnings);
20  strMiscWarning = strWarning;
21 }
22 
23 void SetfLargeWorkForkFound(bool flag)
24 {
25  LOCK(cs_warnings);
26  fLargeWorkForkFound = flag;
27 }
28 
30 {
31  LOCK(cs_warnings);
32  return fLargeWorkForkFound;
33 }
34 
36 {
37  LOCK(cs_warnings);
38  fLargeWorkInvalidChainFound = flag;
39 }
40 
41 std::string GetWarnings(bool verbose)
42 {
43  std::string warnings_concise;
44  std::string warnings_verbose;
45  const std::string warning_separator = "<hr />";
46 
47  LOCK(cs_warnings);
48 
49  // Pre-release build warning
51  warnings_concise = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
52  warnings_verbose = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications").translated;
53  }
54 
55  // Misc warnings like out of disk space and clock is wrong
56  if (strMiscWarning != "") {
57  warnings_concise = strMiscWarning;
58  warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + strMiscWarning;
59  }
60 
61  if (fLargeWorkForkFound) {
62  warnings_concise = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
63  warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.").translated;
64  } else if (fLargeWorkInvalidChainFound) {
65  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.";
66  warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.").translated;
67  }
68 
69  if (verbose) return warnings_verbose;
70  else return warnings_concise;
71 }
static RecursiveMutex cs_warnings
Definition: warnings.cpp:12
std::string translated
Definition: translation.h:18
#define CLIENT_VERSION_IS_RELEASE
void SetfLargeWorkInvalidChainFound(bool flag)
Definition: warnings.cpp:35
#define LOCK(cs)
Definition: sync.h:179
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:36
bool GetfLargeWorkForkFound()
Definition: warnings.cpp:29
void SetMiscWarning(const std::string &strWarning)
Definition: warnings.cpp:17
std::string GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.
Definition: warnings.cpp:41
void SetfLargeWorkForkFound(bool flag)
Definition: warnings.cpp:23
static std::string strMiscWarning GUARDED_BY(cs_warnings)