You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

warnings.cpp 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2016 The Starwels developers
  3. // Distributed under the MIT software license, see the accompanying
  4. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. #include "sync.h"
  6. #include "clientversion.h"
  7. #include "util.h"
  8. #include "warnings.h"
  9. CCriticalSection cs_warnings;
  10. std::string strMiscWarning;
  11. bool fLargeWorkForkFound = false;
  12. bool fLargeWorkInvalidChainFound = false;
  13. void SetMiscWarning(const std::string& strWarning)
  14. {
  15. LOCK(cs_warnings);
  16. strMiscWarning = strWarning;
  17. }
  18. void SetfLargeWorkForkFound(bool flag)
  19. {
  20. LOCK(cs_warnings);
  21. fLargeWorkForkFound = flag;
  22. }
  23. bool GetfLargeWorkForkFound()
  24. {
  25. LOCK(cs_warnings);
  26. return fLargeWorkForkFound;
  27. }
  28. void SetfLargeWorkInvalidChainFound(bool flag)
  29. {
  30. LOCK(cs_warnings);
  31. fLargeWorkInvalidChainFound = flag;
  32. }
  33. std::string GetWarnings(const std::string& strFor)
  34. {
  35. std::string strStatusBar;
  36. std::string strRPC;
  37. std::string strGUI;
  38. const std::string uiAlertSeperator = "<hr />";
  39. LOCK(cs_warnings);
  40. if (!CLIENT_VERSION_IS_RELEASE) {
  41. strStatusBar = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
  42. strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
  43. }
  44. if (gArgs.GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
  45. strStatusBar = strRPC = strGUI = "testsafemode enabled";
  46. // Misc warnings like out of disk space and clock is wrong
  47. if (strMiscWarning != "")
  48. {
  49. strStatusBar = strMiscWarning;
  50. strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + strMiscWarning;
  51. }
  52. if (fLargeWorkForkFound)
  53. {
  54. strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
  55. strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
  56. }
  57. else if (fLargeWorkInvalidChainFound)
  58. {
  59. 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.";
  60. 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.");
  61. }
  62. if (strFor == "gui")
  63. return strGUI;
  64. else if (strFor == "statusbar")
  65. return strStatusBar;
  66. else if (strFor == "rpc")
  67. return strRPC;
  68. assert(!"GetWarnings(): invalid parameter");
  69. return "error";
  70. }