LCOV - code coverage report
Current view: top level - src - warnings.cpp (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 23 26 88.5 %
Date: 2026-06-25 07:23:51 Functions: 3 3 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2             : // Copyright (c) 2009-2020 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             : #include <hash.h>
      13             : 
      14             : #include <vector>
      15             : 
      16             : static GlobalMutex g_warnings_mutex;
      17             : static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
      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       23606 : void SetfLargeWorkInvalidChainFound(bool flag)
      27             : {
      28       23606 :     LOCK(g_warnings_mutex);
      29       23606 :     fLargeWorkInvalidChainFound = flag;
      30       23606 : }
      31             : 
      32           4 : bilingual_str GetWarnings(bool verbose)
      33             : {
      34           4 :     bilingual_str warnings_concise;
      35           4 :     std::vector<bilingual_str> warnings_verbose;
      36             : 
      37           4 :     LOCK(g_warnings_mutex);
      38             : 
      39             :     // Pre-release build warning
      40             :     if (!CLIENT_VERSION_IS_RELEASE) {
      41           4 :         warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
      42           4 :         warnings_verbose.emplace_back(warnings_concise);
      43             :     }
      44             : 
      45             :     // Misc warnings like out of disk space and clock is wrong
      46           4 :     if (!g_misc_warnings.empty()) {
      47           1 :         warnings_concise = g_misc_warnings;
      48           1 :         warnings_verbose.emplace_back(warnings_concise);
      49           1 :     }
      50             : 
      51           4 :     if (fLargeWorkInvalidChainFound) {
      52           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.");
      53           0 :         warnings_verbose.emplace_back(warnings_concise);
      54           0 :     }
      55             : 
      56           4 :     if (verbose) {
      57           1 :         return Join(warnings_verbose, Untranslated("<hr />"));
      58             :     }
      59             : 
      60           3 :     return warnings_concise;
      61           4 : }

Generated by: LCOV version 1.16