[tests] fixup dbcrash interaction with add_nodes()
[bitcoinplatinum.git] / src / warnings.cpp
blobd4e33b701a8a8d1b8d0761936bbff81f64a2ef00
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 std::string GetWarnings(const std::string& strFor)
42 std::string strStatusBar;
43 std::string strRPC;
44 std::string strGUI;
45 const std::string uiAlertSeperator = "<hr />";
47 LOCK(cs_warnings);
49 if (!CLIENT_VERSION_IS_RELEASE) {
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");
54 if (gArgs.GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
55 strStatusBar = strRPC = strGUI = "testsafemode enabled";
57 // Misc warnings like out of disk space and clock is wrong
58 if (strMiscWarning != "")
60 strStatusBar = strMiscWarning;
61 strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + strMiscWarning;
64 if (fLargeWorkForkFound)
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.");
69 else if (fLargeWorkInvalidChainFound)
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.");
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";