Bitcoin ABC 0.32.12
P2P Digital Currency
warnings.cpp
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 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 <clientversion.h>
9#include <common/system.h>
10#include <sync.h>
11#include <util/string.h>
12#include <util/translation.h>
13
14#include <vector>
15
16using util::Join;
17
20static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false;
21static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
22
23void SetMiscWarning(const bilingual_str &warning) {
25 g_misc_warnings = warning;
26}
27
28void SetfLargeWorkForkFound(bool flag) {
30 fLargeWorkForkFound = flag;
31}
32
35 return fLargeWorkForkFound;
36}
37
40 fLargeWorkInvalidChainFound = flag;
41}
42
44 bilingual_str warnings_concise;
45 std::vector<bilingual_str> warnings_verbose;
46
48
49 // Pre-release build warning
50 if (!CLIENT_VERSION_IS_RELEASE) {
51 warnings_concise = _(
52 "This is a pre-release test build - use at your own risk - do not "
53 "use for mining or merchant applications");
54 warnings_verbose.emplace_back(warnings_concise);
55 }
56
57 // Misc warnings like out of disk space and clock is wrong
58 if (!g_misc_warnings.empty()) {
59 warnings_concise = g_misc_warnings;
60 warnings_verbose.emplace_back(warnings_concise);
61 }
62
63 if (fLargeWorkForkFound) {
64 warnings_concise = _(
65 "Warning: The network does not appear to fully agree! Some miners "
66 "appear to be experiencing issues.");
67 warnings_verbose.emplace_back(warnings_concise);
68 } else if (fLargeWorkInvalidChainFound) {
69 warnings_concise = _(
70 "Warning: We do not appear to fully agree with our peers! You may "
71 "need to upgrade, or other nodes may need to upgrade.");
72 warnings_verbose.emplace_back(warnings_concise);
73 }
74
75 if (verbose) {
76 return Join(warnings_verbose, Untranslated("<hr />"));
77 }
78
79 return warnings_concise;
80}
Different type to mark Mutex at global scope.
Definition: sync.h:144
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
Definition: string.h:105
Bilingual messages:
Definition: translation.h:17
#define LOCK(cs)
Definition: sync.h:306
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:68
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:36
bilingual_str GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.
Definition: warnings.cpp:43
void SetfLargeWorkInvalidChainFound(bool flag)
Definition: warnings.cpp:38
static GlobalMutex g_warnings_mutex
Definition: warnings.cpp:18
void SetfLargeWorkForkFound(bool flag)
Definition: warnings.cpp:28
bool GetfLargeWorkForkFound()
Definition: warnings.cpp:33
void SetMiscWarning(const bilingual_str &warning)
Definition: warnings.cpp:23
static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex)