LCOV - code coverage report
Current view: top level - src - warnings.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 33 37 89.2 %
Date: 2020-09-26 01:30:44 Functions: 7 7 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2             : // Copyright (c) 2009-2019 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 <util/string.h>
      10             : #include <util/system.h>
      11             : #include <util/translation.h>
      12             : 
      13             : #include <vector>
      14             : 
      15         640 : static Mutex g_warnings_mutex;
      16         640 : static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
      17             : static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false;
      18             : static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
      19             : 
      20           6 : void SetMiscWarning(const bilingual_str& warning)
      21             : {
      22           6 :     LOCK(g_warnings_mutex);
      23           6 :     g_misc_warnings = warning;
      24           6 : }
      25             : 
      26       38247 : void SetfLargeWorkForkFound(bool flag)
      27             : {
      28       38247 :     LOCK(g_warnings_mutex);
      29       38247 :     fLargeWorkForkFound = flag;
      30       38247 : }
      31             : 
      32          13 : bool GetfLargeWorkForkFound()
      33             : {
      34          13 :     LOCK(g_warnings_mutex);
      35          13 :     return fLargeWorkForkFound;
      36          13 : }
      37             : 
      38       38260 : void SetfLargeWorkInvalidChainFound(bool flag)
      39             : {
      40       38260 :     LOCK(g_warnings_mutex);
      41       38260 :     fLargeWorkInvalidChainFound = flag;
      42       38260 : }
      43             : 
      44         412 : bilingual_str GetWarnings(bool verbose)
      45             : {
      46         412 :     bilingual_str warnings_concise;
      47         412 :     std::vector<bilingual_str> warnings_verbose;
      48             : 
      49         412 :     LOCK(g_warnings_mutex);
      50             : 
      51             :     // Pre-release build warning
      52             :     if (!CLIENT_VERSION_IS_RELEASE) {
      53         412 :         warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
      54         412 :         warnings_verbose.emplace_back(warnings_concise);
      55             :     }
      56             : 
      57             :     // Misc warnings like out of disk space and clock is wrong
      58         412 :     if (!g_misc_warnings.empty()) {
      59           4 :         warnings_concise = g_misc_warnings;
      60           4 :         warnings_verbose.emplace_back(warnings_concise);
      61             :     }
      62             : 
      63         412 :     if (fLargeWorkForkFound) {
      64           0 :         warnings_concise = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
      65           0 :         warnings_verbose.emplace_back(warnings_concise);
      66         412 :     } else if (fLargeWorkInvalidChainFound) {
      67           0 :         warnings_concise = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
      68           0 :         warnings_verbose.emplace_back(warnings_concise);
      69             :     }
      70             : 
      71         412 :     if (verbose) {
      72           1 :         return Join(warnings_verbose, Untranslated("<hr />"));
      73             :     }
      74             : 
      75         411 :     return warnings_concise;
      76         412 : }

Generated by: LCOV version 1.15