mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
376a6a04f1
7aab8d1024996c7c422bd34a8226df0117b813f7 [style] Code style fixups in GetWarnings() (John Newbery) 492c6dc1e742a62599dc6d5ba6c3896825b5144f util: change GetWarnings parameter to bool (John Newbery) 869b6314fd180856b6054fff28b5de994252c54c [qt] remove unused parameter from getWarnings() (John Newbery) Pull request description: `GetWarnings()` changes the format of the output warning string based on a passed-in string argument that can be set to "gui" or "statusbar". Change the argument to a bool: - there are only two types of behaviour, so a bool is a more natural argument type - changing the name to `verbose` does not set any expectations for the how the calling code will use the returned string (currently, `statusbar` is used for RPC warnings, not a status bar) - removes some error-handling code for when the passed-in string is not one of the two strings expected. ACKs for top commit: laanwj: code review ACK 7aab8d1024996c7c422bd34a8226df0117b813f7 practicalswift: ACK 7aab8d1024996c7c422bd34a8226df0117b813f7 -- diff looks correct :) MarcoFalke: ACK 7aab8d1024996c7c422bd34a8226df0117b813f7 otherwise. promag: Code review ACK 7aab8d1024996c7c422bd34a8226df0117b813f7. Tree-SHA512: 75882c6e3e44aa9586411b803149b36ba487f4eb9cac3f5c8f07cd9f586870bba4488a51e674cf8147f05718534f482836e6a4e3f66e0d4ef6821900c7dfd04e
73 lines
2.6 KiB
C++
73 lines
2.6 KiB
C++
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2016 The Bitcoin Core developers
|
|
// 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/system.h>
|
|
#include <util/translation.h>
|
|
#include <hash.h>
|
|
|
|
static Mutex g_warnings_mutex;
|
|
static std::string strMiscWarning GUARDED_BY(g_warnings_mutex);
|
|
static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false;
|
|
static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
|
|
|
|
void SetMiscWarning(const std::string& strWarning)
|
|
{
|
|
LOCK(g_warnings_mutex);
|
|
strMiscWarning = strWarning;
|
|
}
|
|
|
|
void SetfLargeWorkForkFound(bool flag)
|
|
{
|
|
LOCK(g_warnings_mutex);
|
|
fLargeWorkForkFound = flag;
|
|
}
|
|
|
|
bool GetfLargeWorkForkFound()
|
|
{
|
|
LOCK(g_warnings_mutex);
|
|
return fLargeWorkForkFound;
|
|
}
|
|
|
|
void SetfLargeWorkInvalidChainFound(bool flag)
|
|
{
|
|
LOCK(g_warnings_mutex);
|
|
fLargeWorkInvalidChainFound = flag;
|
|
}
|
|
|
|
std::string GetWarnings(bool verbose)
|
|
{
|
|
std::string warnings_concise;
|
|
std::string warnings_verbose;
|
|
const std::string warning_separator = "<hr />";
|
|
|
|
LOCK(g_warnings_mutex);
|
|
|
|
// Pre-release build warning
|
|
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 = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications").translated;
|
|
}
|
|
|
|
// Misc warnings like out of disk space and clock is wrong
|
|
if (strMiscWarning != "") {
|
|
warnings_concise = strMiscWarning;
|
|
warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + strMiscWarning;
|
|
}
|
|
|
|
if (fLargeWorkForkFound) {
|
|
warnings_concise = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
|
|
warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.").translated;
|
|
} 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 += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.").translated;
|
|
}
|
|
|
|
if (verbose) return warnings_verbose;
|
|
else return warnings_concise;
|
|
}
|