BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
warnings.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2018 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 <sync.h>
7 #include <clientversion.h>
8 #include <util.h>
9 #include <warnings.h>
10 
12 std::string strMiscWarning GUARDED_BY(cs_warnings);
13 bool fLargeWorkForkFound GUARDED_BY(cs_warnings) = false;
14 bool fLargeWorkInvalidChainFound GUARDED_BY(cs_warnings) = false;
15 
16 void SetMiscWarning(const std::string& strWarning)
17 {
19  strMiscWarning = strWarning;
20 }
21 
22 void SetfLargeWorkForkFound(bool flag)
23 {
25  fLargeWorkForkFound = flag;
26 }
27 
29 {
31  return fLargeWorkForkFound;
32 }
33 
35 {
37  fLargeWorkInvalidChainFound = flag;
38 }
39 
40 std::string GetWarnings(const std::string& strFor)
41 {
42  std::string strStatusBar;
43  std::string strGUI;
44  const std::string uiAlertSeperator = "<hr />";
45 
47 
49  strStatusBar = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
50  strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
51  }
52 
53  // Misc warnings like out of disk space and clock is wrong
54  if (strMiscWarning != "")
55  {
56  strStatusBar = strMiscWarning;
57  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + strMiscWarning;
58  }
59 
60  if (fLargeWorkForkFound)
61  {
62  strStatusBar = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
63  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
64  }
65  else if (fLargeWorkInvalidChainFound)
66  {
67  strStatusBar = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
68  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
69  }
70 
71  if (strFor == "gui")
72  return strGUI;
73  else if (strFor == "statusbar")
74  return strStatusBar;
75  assert(!"GetWarnings(): invalid parameter");
76  return "error";
77 }
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.
Definition: warnings.cpp:40
CCriticalSection cs_warnings
Definition: warnings.cpp:11
#define CLIENT_VERSION_IS_RELEASE
void SetfLargeWorkInvalidChainFound(bool flag)
Definition: warnings.cpp:34
#define LOCK(cs)
Definition: sync.h:181
bool GetfLargeWorkForkFound()
Definition: warnings.cpp:28
std::string strMiscWarning GUARDED_BY(cs_warnings)
void SetMiscWarning(const std::string &strWarning)
Definition: warnings.cpp:16
void SetfLargeWorkForkFound(bool flag)
Definition: warnings.cpp:22
std::string _(const char *psz)
Translation function.
Definition: util.h:50