PIVX Core  5.6.99
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 "sync.h"
9 #include "clientversion.h"
10 #include "util/system.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 
42 {
45 }
46 
47 std::string GetWarnings(const std::string& strFor)
48 {
49  std::string strStatusBar;
50  std::string strRPC;
51  std::string strGUI;
52  const std::string uiAlertSeperator = "\n";
53 
55 
57  strStatusBar = "This is a pre-release test build - use at your own risk - do not use for staking or merchant applications!";
58  strGUI = _("This is a pre-release test build - use at your own risk - do not use for staking or merchant applications!");
59  }
60 
61  if (gArgs.GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
62  strStatusBar = strRPC = strGUI = "testsafemode enabled";
63 
64  // Misc warnings like out of disk space and clock is wrong
65  if (!strMiscWarning.empty()) {
66  strStatusBar = strMiscWarning;
67  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + strMiscWarning;
68  }
69 
70  if (fLargeWorkForkFound) {
71  strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
72  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
73  } else if (fLargeWorkInvalidChainFound) {
74  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.";
75  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.");
76  }
77 
78  if (strFor == "gui")
79  return strGUI;
80  else if (strFor == "statusbar")
81  return strStatusBar;
82  else if (strFor == "rpc")
83  return strRPC;
84  assert(!"GetWarnings() : invalid parameter");
85  return "error";
86 }
87 
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:465
@ LOCK
Definition: lockunlock.h:16
#define CLIENT_VERSION_IS_RELEASE
Definition: pivx-config.h:15
ArgsManager gArgs
Definition: system.cpp:89
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a Optional result.
Definition: system.h:65
void SetfLargeWorkInvalidChainFound(bool flag)
Definition: warnings.cpp:35
std::string strMiscWarning
Definition: warnings.cpp:13
void SetfLargeWorkForkFound(bool flag)
Definition: warnings.cpp:23
bool GetfLargeWorkForkFound()
Definition: warnings.cpp:29
RecursiveMutex cs_warnings
Definition: warnings.cpp:12
std::string GetWarnings(const std::string &strFor)
Definition: warnings.cpp:47
bool GetfLargeWorkInvalidChainFound()
Definition: warnings.cpp:41
void SetMiscWarning(const std::string &strWarning)
Definition: warnings.cpp:17
bool fLargeWorkInvalidChainFound
Definition: warnings.cpp:15
bool fLargeWorkForkFound
Definition: warnings.cpp:14