mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-09 08:43:04 +01:00
Eliminate data races for strMiscWarning and fLargeWork*Found.
This moves all access to these datastructures through accessor functions and protects them with a lock.
This commit is contained in:
33
src/util.cpp
33
src/util.cpp
@@ -108,6 +108,7 @@ bool fDebug = false;
|
||||
bool fPrintToConsole = false;
|
||||
bool fPrintToDebugLog = true;
|
||||
|
||||
CCriticalSection cs_warnings;
|
||||
string strMiscWarning;
|
||||
bool fLargeWorkForkFound = false;
|
||||
bool fLargeWorkInvalidChainFound = false;
|
||||
@@ -813,6 +814,36 @@ std::string CopyrightHolders(const std::string& strPrefix)
|
||||
return strCopyrightHolders;
|
||||
}
|
||||
|
||||
void SetMiscWarning(const std::string& strWarning)
|
||||
{
|
||||
LOCK(cs_warnings);
|
||||
strMiscWarning = strWarning;
|
||||
}
|
||||
|
||||
void SetfLargeWorkForkFound(bool flag)
|
||||
{
|
||||
LOCK(cs_warnings);
|
||||
fLargeWorkForkFound = flag;
|
||||
}
|
||||
|
||||
bool GetfLargeWorkForkFound()
|
||||
{
|
||||
LOCK(cs_warnings);
|
||||
return fLargeWorkForkFound;
|
||||
}
|
||||
|
||||
void SetfLargeWorkInvalidChainFound(bool flag)
|
||||
{
|
||||
LOCK(cs_warnings);
|
||||
fLargeWorkInvalidChainFound = flag;
|
||||
}
|
||||
|
||||
bool GetfLargeWorkInvalidChainFound()
|
||||
{
|
||||
LOCK(cs_warnings);
|
||||
return fLargeWorkInvalidChainFound;
|
||||
}
|
||||
|
||||
std::string GetWarnings(const std::string& strFor)
|
||||
{
|
||||
string strStatusBar;
|
||||
@@ -820,6 +851,8 @@ std::string GetWarnings(const std::string& strFor)
|
||||
string strGUI;
|
||||
const string uiAlertSeperator = "<hr />";
|
||||
|
||||
LOCK(cs_warnings);
|
||||
|
||||
if (!CLIENT_VERSION_IS_RELEASE) {
|
||||
strStatusBar = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
|
||||
strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
|
||||
|
||||
Reference in New Issue
Block a user