dogecoin/src/warnings.cpp

77 lines
2.2 KiB
C++
Raw Normal View History

2016-11-30 07:07:42 +01:00
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2019 The Bitcoin Core developers
2016-11-30 07:07:42 +01:00
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <warnings.h>
#include <sync.h>
#include <util/string.h>
scripted-diff: Move util files to separate directory. -BEGIN VERIFY SCRIPT- mkdir -p src/util git mv src/util.h src/util/system.h git mv src/util.cpp src/util/system.cpp git mv src/utilmemory.h src/util/memory.h git mv src/utilmoneystr.h src/util/moneystr.h git mv src/utilmoneystr.cpp src/util/moneystr.cpp git mv src/utilstrencodings.h src/util/strencodings.h git mv src/utilstrencodings.cpp src/util/strencodings.cpp git mv src/utiltime.h src/util/time.h git mv src/utiltime.cpp src/util/time.cpp sed -i 's/<util\.h>/<util\/system\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilmemory\.h>/<util\/memory\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilmoneystr\.h>/<util\/moneystr\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilstrencodings\.h>/<util\/strencodings\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utiltime\.h>/<util\/time\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/BITCOIN_UTIL_H/BITCOIN_UTIL_SYSTEM_H/g' src/util/system.h sed -i 's/BITCOIN_UTILMEMORY_H/BITCOIN_UTIL_MEMORY_H/g' src/util/memory.h sed -i 's/BITCOIN_UTILMONEYSTR_H/BITCOIN_UTIL_MONEYSTR_H/g' src/util/moneystr.h sed -i 's/BITCOIN_UTILSTRENCODINGS_H/BITCOIN_UTIL_STRENCODINGS_H/g' src/util/strencodings.h sed -i 's/BITCOIN_UTILTIME_H/BITCOIN_UTIL_TIME_H/g' src/util/time.h sed -i 's/ util\.\(h\|cpp\)/ util\/system\.\1/g' src/Makefile.am sed -i 's/utilmemory\.\(h\|cpp\)/util\/memory\.\1/g' src/Makefile.am sed -i 's/utilmoneystr\.\(h\|cpp\)/util\/moneystr\.\1/g' src/Makefile.am sed -i 's/utilstrencodings\.\(h\|cpp\)/util\/strencodings\.\1/g' src/Makefile.am sed -i 's/utiltime\.\(h\|cpp\)/util\/time\.\1/g' src/Makefile.am sed -i 's/-> util ->/-> util\/system ->/' test/lint/lint-circular-dependencies.sh sed -i 's/src\/util\.cpp/src\/util\/system\.cpp/g' test/lint/lint-format-strings.py test/lint/lint-locale-dependence.sh sed -i 's/src\/utilmoneystr\.cpp/src\/util\/moneystr\.cpp/g' test/lint/lint-locale-dependence.sh sed -i 's/src\/utilstrencodings\.\(h\|cpp\)/src\/util\/strencodings\.\1/g' test/lint/lint-locale-dependence.sh sed -i 's/src\\utilstrencodings\.cpp/src\\util\\strencodings\.cpp/' build_msvc/libbitcoinconsensus/libbitcoinconsensus.vcxproj -END VERIFY SCRIPT-
2018-10-23 00:51:11 +02:00
#include <util/system.h>
#include <util/translation.h>
2016-11-30 07:07:42 +01:00
#include <vector>
static Mutex g_warnings_mutex;
static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false;
static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
2016-11-30 07:07:42 +01:00
void SetMiscWarning(const bilingual_str& warning)
2016-11-30 07:07:42 +01:00
{
LOCK(g_warnings_mutex);
g_misc_warnings = warning;
2016-11-30 07:07:42 +01:00
}
void SetfLargeWorkForkFound(bool flag)
{
LOCK(g_warnings_mutex);
2016-11-30 07:07:42 +01:00
fLargeWorkForkFound = flag;
}
bool GetfLargeWorkForkFound()
{
LOCK(g_warnings_mutex);
2016-11-30 07:07:42 +01:00
return fLargeWorkForkFound;
}
void SetfLargeWorkInvalidChainFound(bool flag)
{
LOCK(g_warnings_mutex);
2016-11-30 07:07:42 +01:00
fLargeWorkInvalidChainFound = flag;
}
bilingual_str GetWarnings(bool verbose)
2016-11-30 07:07:42 +01:00
{
bilingual_str warnings_concise;
std::vector<bilingual_str> warnings_verbose;
2016-11-30 07:07:42 +01:00
LOCK(g_warnings_mutex);
2016-11-30 07:07:42 +01:00
// Pre-release build warning
2016-11-30 07:07:42 +01:00
if (!CLIENT_VERSION_IS_RELEASE) {
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 07:07:42 +01:00
}
// Misc warnings like out of disk space and clock is wrong
if (!g_misc_warnings.empty()) {
warnings_concise = g_misc_warnings;
warnings_verbose.emplace_back(warnings_concise);
2016-11-30 07:07:42 +01:00
}
if (fLargeWorkForkFound) {
warnings_concise = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
warnings_verbose.emplace_back(warnings_concise);
} else if (fLargeWorkInvalidChainFound) {
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) {
return Join(warnings_verbose, Untranslated("<hr />"));
2016-11-30 07:07:42 +01:00
}
return warnings_concise;
2016-11-30 07:07:42 +01:00
}