Fabcoin Core  0.16.2
P2P Digital Currency
warnings.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2017 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;
13 bool fLargeWorkForkFound = false;
15 
16 void SetMiscWarning(const std::string& strWarning)
17 {
18  LOCK(cs_warnings);
19  strMiscWarning = strWarning;
20 }
21 
22 void SetfLargeWorkForkFound(bool flag)
23 {
24  LOCK(cs_warnings);
25  fLargeWorkForkFound = flag;
26 }
27 
29 {
30  LOCK(cs_warnings);
31  return fLargeWorkForkFound;
32 }
33 
35 {
36  LOCK(cs_warnings);
38 }
39 
40 std::string GetWarnings(const std::string& strFor)
41 {
42  std::string strStatusBar;
43  std::string strRPC;
44  std::string strGUI;
45  const std::string uiAlertSeperator = "<hr />";
46 
47  LOCK(cs_warnings);
48 
50  strStatusBar = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
51  strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
52  }
53 
54  if (gArgs.GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
55  strStatusBar = strRPC = strGUI = "testsafemode enabled";
56 
57  // Misc warnings like out of disk space and clock is wrong
58  if (strMiscWarning != "")
59  {
60  strStatusBar = strMiscWarning;
61  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + strMiscWarning;
62  }
63 
65  {
66  strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
67  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
68  }
70  {
71  strStatusBar = strRPC = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
72  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.");
73  }
74 
75  if (strFor == "gui")
76  return strGUI;
77  else if (strFor == "statusbar")
78  return strStatusBar;
79  else if (strFor == "rpc")
80  return strRPC;
81  assert(!"GetWarnings(): invalid parameter");
82  return "error";
83 }
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
Definition: util.cpp:520
assert(len-trim+(2 *lenIndices)<=WIDTH)
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.
Definition: warnings.cpp:40
bool fLargeWorkForkFound
Definition: warnings.cpp:13
bool fLargeWorkInvalidChainFound
Definition: warnings.cpp:14
CCriticalSection cs_warnings
Definition: warnings.cpp:11
void SetfLargeWorkInvalidChainFound(bool flag)
Definition: warnings.cpp:34
#define LOCK(cs)
Definition: sync.h:175
#define CLIENT_VERSION_IS_RELEASE
std::string strMiscWarning
Definition: warnings.cpp:12
ArgsManager gArgs
Definition: util.cpp:94
bool GetfLargeWorkForkFound()
Definition: warnings.cpp:28
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: Call Translate signal on UI interface, which returns a boost::optional result...
Definition: util.h:71
Wrapped boost mutex: supports recursive locking, but no waiting TODO: We should move away from using ...
Definition: sync.h:91