Merge #10471: Denote functions CNode::GetRecvVersion() and CNode::GetRefCount() ...
[bitcoinplatinum.git] / src / warnings.cpp
blob2c1b1b0e12d8f784f4f41614e0428524827a8e1c
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.
6 #include "sync.h"
7 #include "clientversion.h"
8 #include "util.h"
9 #include "warnings.h"
11 CCriticalSection cs_warnings;
12 std::string strMiscWarning;
13 bool fLargeWorkForkFound = false;
14 bool fLargeWorkInvalidChainFound = false;
16 void SetMiscWarning(const std::string& strWarning)
18 LOCK(cs_warnings);
19 strMiscWarning = strWarning;
22 void SetfLargeWorkForkFound(bool flag)
24 LOCK(cs_warnings);
25 fLargeWorkForkFound = flag;
28 bool GetfLargeWorkForkFound()
30 LOCK(cs_warnings);
31 return fLargeWorkForkFound;
34 void SetfLargeWorkInvalidChainFound(bool flag)
36 LOCK(cs_warnings);
37 fLargeWorkInvalidChainFound = flag;
40 bool GetfLargeWorkInvalidChainFound()
42 LOCK(cs_warnings);
43 return fLargeWorkInvalidChainFound;
46 std::string GetWarnings(const std::string& strFor)
48 std::string strStatusBar;
49 std::string strRPC;
50 std::string strGUI;
51 const std::string uiAlertSeperator = "<hr />";
53 LOCK(cs_warnings);
55 if (!CLIENT_VERSION_IS_RELEASE) {
56 strStatusBar = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
57 strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
60 if (GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
61 strStatusBar = strRPC = strGUI = "testsafemode enabled";
63 // Misc warnings like out of disk space and clock is wrong
64 if (strMiscWarning != "")
66 strStatusBar = strMiscWarning;
67 strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + strMiscWarning;
70 if (fLargeWorkForkFound)
72 strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
73 strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
75 else if (fLargeWorkInvalidChainFound)
77 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.";
78 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.");
81 if (strFor == "gui")
82 return strGUI;
83 else if (strFor == "statusbar")
84 return strStatusBar;
85 else if (strFor == "rpc")
86 return strRPC;
87 assert(!"GetWarnings(): invalid parameter");
88 return "error";