2016-11-30 06:07:42 +00:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2020-12-31 09:48:25 +01:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2016-11-30 06:07:42 +00:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2019-06-17 10:56:52 +03:00
|
|
|
#include <warnings.h>
|
|
|
|
|
2017-11-10 13:57:53 +13:00
|
|
|
#include <sync.h>
|
2020-06-10 11:21:40 +03:00
|
|
|
#include <util/string.h>
|
2018-10-22 15:51:11 -07:00
|
|
|
#include <util/system.h>
|
2019-06-17 10:56:52 +03:00
|
|
|
#include <util/translation.h>
|
2016-11-30 06:07:42 +00:00
|
|
|
|
2020-06-10 11:21:40 +03:00
|
|
|
#include <vector>
|
|
|
|
|
2020-06-09 09:35:10 +03:00
|
|
|
static Mutex g_warnings_mutex;
|
2020-06-10 12:14:32 +03:00
|
|
|
static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
|
2020-06-09 09:35:10 +03:00
|
|
|
static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
|
2016-11-30 06:07:42 +00:00
|
|
|
|
2020-06-10 12:14:32 +03:00
|
|
|
void SetMiscWarning(const bilingual_str& warning)
|
2016-11-30 06:07:42 +00:00
|
|
|
{
|
2020-06-09 09:35:10 +03:00
|
|
|
LOCK(g_warnings_mutex);
|
2020-06-10 12:14:32 +03:00
|
|
|
g_misc_warnings = warning;
|
2016-11-30 06:07:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetfLargeWorkInvalidChainFound(bool flag)
|
|
|
|
{
|
2020-06-09 09:35:10 +03:00
|
|
|
LOCK(g_warnings_mutex);
|
2016-11-30 06:07:42 +00:00
|
|
|
fLargeWorkInvalidChainFound = flag;
|
|
|
|
}
|
|
|
|
|
2020-06-10 11:44:48 +03:00
|
|
|
bilingual_str GetWarnings(bool verbose)
|
2016-11-30 06:07:42 +00:00
|
|
|
{
|
2020-06-10 11:21:40 +03:00
|
|
|
bilingual_str warnings_concise;
|
|
|
|
std::vector<bilingual_str> warnings_verbose;
|
2016-11-30 06:07:42 +00:00
|
|
|
|
2020-06-09 09:35:10 +03:00
|
|
|
LOCK(g_warnings_mutex);
|
2016-11-30 06:07:42 +00:00
|
|
|
|
2019-12-15 12:53:51 -03:00
|
|
|
// Pre-release build warning
|
2016-11-30 06:07:42 +00:00
|
|
|
if (!CLIENT_VERSION_IS_RELEASE) {
|
2020-06-10 11:21:40 +03: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 06:07:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Misc warnings like out of disk space and clock is wrong
|
2020-06-10 12:14:32 +03:00
|
|
|
if (!g_misc_warnings.empty()) {
|
|
|
|
warnings_concise = g_misc_warnings;
|
2020-06-10 11:21:40 +03:00
|
|
|
warnings_verbose.emplace_back(warnings_concise);
|
2016-11-30 06:07:42 +00:00
|
|
|
}
|
|
|
|
|
2020-09-07 07:58:42 +02:00
|
|
|
if (fLargeWorkInvalidChainFound) {
|
2020-06-10 11:21:40 +03: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 11:44:48 +03:00
|
|
|
return Join(warnings_verbose, Untranslated("<hr />"));
|
2016-11-30 06:07:42 +00:00
|
|
|
}
|
|
|
|
|
2020-06-10 11:44:48 +03:00
|
|
|
return warnings_concise;
|
2016-11-30 06:07:42 +00:00
|
|
|
}
|