2016-11-30 03:07:42 -03:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2019-12-30 06:39:22 -03:00
|
|
|
// Copyright (c) 2009-2019 The Bitcoin Core developers
|
2016-11-30 03:07:42 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2019-06-17 03:56:52 -04:00
|
|
|
#include <warnings.h>
|
|
|
|
|
2017-11-09 21:57:53 -03:00
|
|
|
#include <sync.h>
|
2020-06-10 04:21:40 -04:00
|
|
|
#include <util/string.h>
|
2018-10-22 19:51:11 -03:00
|
|
|
#include <util/system.h>
|
2019-06-17 03:56:52 -04:00
|
|
|
#include <util/translation.h>
|
2016-11-30 03:07:42 -03:00
|
|
|
|
2020-06-10 04:21:40 -04:00
|
|
|
#include <vector>
|
|
|
|
|
2020-06-09 02:35:10 -04:00
|
|
|
static Mutex g_warnings_mutex;
|
2020-06-10 05:14:32 -04:00
|
|
|
static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
|
2020-06-09 02:35:10 -04:00
|
|
|
static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false;
|
|
|
|
static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
|
2016-11-30 03:07:42 -03:00
|
|
|
|
2020-06-10 05:14:32 -04:00
|
|
|
void SetMiscWarning(const bilingual_str& warning)
|
2016-11-30 03:07:42 -03:00
|
|
|
{
|
2020-06-09 02:35:10 -04:00
|
|
|
LOCK(g_warnings_mutex);
|
2020-06-10 05:14:32 -04:00
|
|
|
g_misc_warnings = warning;
|
2016-11-30 03:07:42 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetfLargeWorkForkFound(bool flag)
|
|
|
|
{
|
2020-06-09 02:35:10 -04:00
|
|
|
LOCK(g_warnings_mutex);
|
2016-11-30 03:07:42 -03:00
|
|
|
fLargeWorkForkFound = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetfLargeWorkForkFound()
|
|
|
|
{
|
2020-06-09 02:35:10 -04:00
|
|
|
LOCK(g_warnings_mutex);
|
2016-11-30 03:07:42 -03:00
|
|
|
return fLargeWorkForkFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetfLargeWorkInvalidChainFound(bool flag)
|
|
|
|
{
|
2020-06-09 02:35:10 -04:00
|
|
|
LOCK(g_warnings_mutex);
|
2016-11-30 03:07:42 -03:00
|
|
|
fLargeWorkInvalidChainFound = flag;
|
|
|
|
}
|
|
|
|
|
2020-06-10 04:44:48 -04:00
|
|
|
bilingual_str GetWarnings(bool verbose)
|
2016-11-30 03:07:42 -03:00
|
|
|
{
|
2020-06-10 04:21:40 -04:00
|
|
|
bilingual_str warnings_concise;
|
|
|
|
std::vector<bilingual_str> warnings_verbose;
|
2016-11-30 03:07:42 -03:00
|
|
|
|
2020-06-09 02:35:10 -04:00
|
|
|
LOCK(g_warnings_mutex);
|
2016-11-30 03:07:42 -03:00
|
|
|
|
2019-12-15 12:53:51 -03:00
|
|
|
// Pre-release build warning
|
2016-11-30 03:07:42 -03:00
|
|
|
if (!CLIENT_VERSION_IS_RELEASE) {
|
2020-06-10 04:21:40 -04:00
|
|
|
warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
|
|
|
|
warnings_verbose.emplace_back(warnings_concise);
|
2016-11-30 03:07:42 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Misc warnings like out of disk space and clock is wrong
|
2020-06-10 05:14:32 -04:00
|
|
|
if (!g_misc_warnings.empty()) {
|
|
|
|
warnings_concise = g_misc_warnings;
|
2020-06-10 04:21:40 -04:00
|
|
|
warnings_verbose.emplace_back(warnings_concise);
|
2016-11-30 03:07:42 -03:00
|
|
|
}
|
|
|
|
|
2019-12-15 12:53:51 -03:00
|
|
|
if (fLargeWorkForkFound) {
|
2020-06-10 04:21:40 -04:00
|
|
|
warnings_concise = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
|
|
|
|
warnings_verbose.emplace_back(warnings_concise);
|
2019-12-15 12:53:51 -03:00
|
|
|
} else if (fLargeWorkInvalidChainFound) {
|
2020-06-10 04:21:40 -04:00
|
|
|
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.");
|
|
|
|
warnings_verbose.emplace_back(warnings_concise);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (verbose) {
|
2020-06-10 04:44:48 -04:00
|
|
|
return Join(warnings_verbose, Untranslated("<hr />"));
|
2016-11-30 03:07:42 -03:00
|
|
|
}
|
|
|
|
|
2020-06-10 04:44:48 -04:00
|
|
|
return warnings_concise;
|
2016-11-30 03:07:42 -03:00
|
|
|
}
|