Dogecoin Core  1.14.2
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 "alert.h"
7 #include "sync.h"
8 #include "clientversion.h"
9 #include "uint256.h"
10 #include "util.h"
11 #include "utilstrencodings.h"
12 #include "warnings.h"
13 
14 #include <boost/foreach.hpp>
15 
17 std::string strMiscWarning;
18 bool fLargeWorkForkFound = false;
20 
21 void SetMiscWarning(const std::string& strWarning)
22 {
24  strMiscWarning = strWarning;
25 }
26 
27 void SetfLargeWorkForkFound(bool flag)
28 {
30  fLargeWorkForkFound = flag;
31 }
32 
34 {
36  return fLargeWorkForkFound;
37 }
38 
40 {
43 }
44 
46 {
49 }
50 
51 std::string GetWarnings(const std::string& strFor)
52 {
53  int nPriority = 0;
54  std::string strStatusBar;
55  std::string strRPC;
56  std::string strGUI;
57  const std::string uiAlertSeperator = "<hr />";
58 
60 
62  strStatusBar = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
63  strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
64  }
65 
66  if (GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
67  strStatusBar = strRPC = strGUI = "testsafemode enabled";
68 
69  // Misc warnings like out of disk space and clock is wrong
70  if (strMiscWarning != "")
71  {
72  nPriority = 1000;
73  strStatusBar = strMiscWarning;
74  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + strMiscWarning;
75  }
76 
78  {
79  nPriority = 2000;
80  strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
81  strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
82  }
84  {
85  nPriority = 2000;
86  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.";
87  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.");
88  }
89 
90  // Alerts
91  {
93  BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
94  {
95  const CAlert& alert = item.second;
96  if (alert.AppliesToMe() && alert.nPriority > nPriority)
97  {
98  nPriority = alert.nPriority;
99  strStatusBar = strGUI = alert.strStatusBar;
100  }
101  }
102  }
103 
104  if (strFor == "gui")
105  return strGUI;
106  else if (strFor == "statusbar")
107  return strStatusBar;
108  else if (strFor == "rpc")
109  return strRPC;
110  assert(!"GetWarnings(): invalid parameter");
111  return "error";
112 }
CCriticalSection cs_mapAlerts
Definition: alert.cpp:29
map< uint256, CAlert > mapAlerts
Definition: alert.cpp:28
An alert is a combination of a serialized CUnsignedAlert and a signature.
Definition: alert.h:77
bool AppliesToMe() const
Definition: alert.cpp:123
Wrapped boost mutex: supports recursive locking, but no waiting TODO: We should move away from using ...
Definition: sync.h:93
std::string strStatusBar
Definition: alert.h:46
int nPriority
Definition: alert.h:42
256-bit opaque blob.
Definition: uint256.h:123
#define CLIENT_VERSION_IS_RELEASE
Set to true for release, false for prerelease or test build.
Definition: clientversion.h:23
#define LOCK(cs)
Definition: sync.h:177
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
Definition: util.cpp:411
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
Definition: util.h:62
#define PAIRTYPE(t1, t2)
This is needed because the foreach macro can't get over the comma in pair<t1, t2>
void SetfLargeWorkInvalidChainFound(bool flag)
Definition: warnings.cpp:39
std::string strMiscWarning
Definition: warnings.cpp:17
void SetfLargeWorkForkFound(bool flag)
Definition: warnings.cpp:27
bool GetfLargeWorkForkFound()
Definition: warnings.cpp:33
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.
Definition: warnings.cpp:51
bool GetfLargeWorkInvalidChainFound()
Definition: warnings.cpp:45
void SetMiscWarning(const std::string &strWarning)
Definition: warnings.cpp:21
CCriticalSection cs_warnings
Definition: warnings.cpp:16
bool fLargeWorkInvalidChainFound
Definition: warnings.cpp:19
bool fLargeWorkForkFound
Definition: warnings.cpp:18