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