LCOV - code coverage report
Current view: top level - src - warnings.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 5 28 17.9 %
Date: 2023-11-10 23:46:46 Functions: 1 4 25.0 %
Branches: 0 32 0.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2                 :            : // Copyright (c) 2009-2022 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 <common/system.h>
       9                 :            : #include <sync.h>
      10                 :            : #include <util/string.h>
      11                 :            : #include <util/translation.h>
      12                 :            : 
      13                 :            : #include <vector>
      14                 :            : 
      15                 :            : static GlobalMutex g_warnings_mutex;
      16                 :          2 : static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
      17                 :            : static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
      18                 :            : 
      19                 :          0 : void SetMiscWarning(const bilingual_str& warning)
      20                 :            : {
      21                 :          0 :     LOCK(g_warnings_mutex);
      22         [ #  # ]:          0 :     g_misc_warnings = warning;
      23                 :          0 : }
      24                 :            : 
      25                 :        150 : void SetfLargeWorkInvalidChainFound(bool flag)
      26                 :            : {
      27                 :        150 :     LOCK(g_warnings_mutex);
      28                 :        150 :     fLargeWorkInvalidChainFound = flag;
      29                 :        150 : }
      30                 :            : 
      31                 :          0 : bilingual_str GetWarnings(bool verbose)
      32                 :            : {
      33                 :          0 :     bilingual_str warnings_concise;
      34                 :          0 :     std::vector<bilingual_str> warnings_verbose;
      35                 :            : 
      36 [ #  # ][ #  # ]:          0 :     LOCK(g_warnings_mutex);
      37                 :            : 
      38                 :            :     // Pre-release build warning
      39                 :            :     if (!CLIENT_VERSION_IS_RELEASE) {
      40         [ #  # ]:          0 :         warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
      41         [ #  # ]:          0 :         warnings_verbose.emplace_back(warnings_concise);
      42                 :            :     }
      43                 :            : 
      44                 :            :     // Misc warnings like out of disk space and clock is wrong
      45 [ #  # ][ #  # ]:          0 :     if (!g_misc_warnings.empty()) {
      46         [ #  # ]:          0 :         warnings_concise = g_misc_warnings;
      47         [ #  # ]:          0 :         warnings_verbose.emplace_back(warnings_concise);
      48                 :          0 :     }
      49                 :            : 
      50         [ #  # ]:          0 :     if (fLargeWorkInvalidChainFound) {
      51         [ #  # ]:          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.");
      52         [ #  # ]:          0 :         warnings_verbose.emplace_back(warnings_concise);
      53                 :          0 :     }
      54                 :            : 
      55         [ #  # ]:          0 :     if (verbose) {
      56 [ #  # ][ #  # ]:          0 :         return Join(warnings_verbose, Untranslated("<hr />"));
                 [ #  # ]
      57                 :            :     }
      58                 :            : 
      59                 :          0 :     return warnings_concise;
      60                 :          0 : }

Generated by: LCOV version 1.14