LCOV - code coverage report
Current view: top level - src - warnings.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 26 29 89.7 %
Date: 2021-06-29 14:35:33 Functions: 3 3 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 5 6 83.3 %

           Branch data     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                 :            : 
#      13                 :            : #include <vector>
#      14                 :            : 
#      15                 :            : static Mutex g_warnings_mutex;
#      16                 :            : static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
#      17                 :            : static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
#      18                 :            : 
#      19                 :            : void SetMiscWarning(const bilingual_str& warning)
#      20                 :          7 : {
#      21                 :          7 :     LOCK(g_warnings_mutex);
#      22                 :          7 :     g_misc_warnings = warning;
#      23                 :          7 : }
#      24                 :            : 
#      25                 :            : void SetfLargeWorkInvalidChainFound(bool flag)
#      26                 :      66930 : {
#      27                 :      66930 :     LOCK(g_warnings_mutex);
#      28                 :      66930 :     fLargeWorkInvalidChainFound = flag;
#      29                 :      66930 : }
#      30                 :            : 
#      31                 :            : bilingual_str GetWarnings(bool verbose)
#      32                 :        459 : {
#      33                 :        459 :     bilingual_str warnings_concise;
#      34                 :        459 :     std::vector<bilingual_str> warnings_verbose;
#      35                 :            : 
#      36                 :        459 :     LOCK(g_warnings_mutex);
#      37                 :            : 
#      38                 :            :     // Pre-release build warning
#      39                 :        459 :     if (!CLIENT_VERSION_IS_RELEASE) {
#      40                 :        459 :         warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
#      41                 :        459 :         warnings_verbose.emplace_back(warnings_concise);
#      42                 :        459 :     }
#      43                 :            : 
#      44                 :            :     // Misc warnings like out of disk space and clock is wrong
#      45         [ +  + ]:        459 :     if (!g_misc_warnings.empty()) {
#      46                 :          5 :         warnings_concise = g_misc_warnings;
#      47                 :          5 :         warnings_verbose.emplace_back(warnings_concise);
#      48                 :          5 :     }
#      49                 :            : 
#      50         [ -  + ]:        459 :     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         [ +  + ]:        459 :     if (verbose) {
#      56                 :          2 :         return Join(warnings_verbose, Untranslated("<hr />"));
#      57                 :          2 :     }
#      58                 :            : 
#      59                 :        457 :     return warnings_concise;
#      60                 :        457 : }

Generated by: LCOV version 1.14