Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

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 <sync.h>
7 #include <clientversion.h>
8 #include <util.h>
9 #include <warnings.h>
10 #include <hash.h>
11 
13 std::string strMiscWarning;
14 bool fLargeWorkForkFound = false;
16 
17 void SetMiscWarning(const std::string& strWarning)
18 {
20  strMiscWarning = strWarning;
21 }
22 
23 void SetfLargeWorkForkFound(bool flag)
24 {
26  fLargeWorkForkFound = flag;
27 }
28 
30 {
32  return fLargeWorkForkFound;
33 }
34 
36 {
39 }
40 
41 std::string GetWarnings(const std::string& strFor)
42 {
43  std::string strStatusBar;
44  std::string strRPC;
45  std::string strGUI;
46  const std::string uiAlertSeperator = "<hr />";
47 
49 
50  if (!CLIENT_VERSION_IS_RELEASE) {
51  strStatusBar = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
52  strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
53  }
54 
55  if (gArgs.GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
56  strStatusBar = strRPC = strGUI = "testsafemode enabled";
57 
58  // Misc warnings like out of disk space and clock is wrong
59  if (strMiscWarning != "")
60  {
61  strStatusBar = strMiscWarning;
62  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + strMiscWarning;
63  }
64 
66  {
67  strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
68  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
69  }
71  {
72  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.";
73  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.");
74  }
75 
76  if (strFor == "gui")
77  return strGUI;
78  else if (strFor == "statusbar")
79  return strStatusBar;
80  else if (strFor == "rpc")
81  return strRPC;
82  assert(!"GetWarnings(): invalid parameter");
83  return "error";
84 }
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: util.cpp:824
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.
Definition: warnings.cpp:41
bool fLargeWorkForkFound
Definition: warnings.cpp:14
bool fLargeWorkInvalidChainFound
Definition: warnings.cpp:15
CCriticalSection cs_warnings
Definition: warnings.cpp:12
void SetfLargeWorkInvalidChainFound(bool flag)
Definition: warnings.cpp:35
#define LOCK(cs)
Definition: sync.h:178
static const bool DEFAULT_TESTSAFEMODE
Definition: warnings.h:25
std::string strMiscWarning
Definition: warnings.cpp:13
ArgsManager gArgs
Definition: util.cpp:108
bool GetfLargeWorkForkFound()
Definition: warnings.cpp:29
void SetMiscWarning(const std::string &strWarning)
Definition: warnings.cpp:17
void SetfLargeWorkForkFound(bool flag)
Definition: warnings.cpp:23
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
Definition: util.h:92
Wrapped mutex: supports recursive locking, but no waiting TODO: We should move away from using the re...
Definition: sync.h:94
Released under the MIT license