mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +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:
@@ -1183,7 +1183,7 @@ void CheckForkWarningConditions()
|
||||
|
||||
if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > chainActive.Tip()->nChainWork + (GetBlockProof(*chainActive.Tip()) * 6)))
|
||||
{
|
||||
if (!fLargeWorkForkFound && pindexBestForkBase)
|
||||
if (!GetfLargeWorkForkFound() && pindexBestForkBase)
|
||||
{
|
||||
std::string warning = std::string("'Warning: Large-work fork detected, forking after block ") +
|
||||
pindexBestForkBase->phashBlock->ToString() + std::string("'");
|
||||
@@ -1194,18 +1194,18 @@ void CheckForkWarningConditions()
|
||||
LogPrintf("%s: Warning: Large valid fork found\n forking the chain at height %d (%s)\n lasting to height %d (%s).\nChain state database corruption likely.\n", __func__,
|
||||
pindexBestForkBase->nHeight, pindexBestForkBase->phashBlock->ToString(),
|
||||
pindexBestForkTip->nHeight, pindexBestForkTip->phashBlock->ToString());
|
||||
fLargeWorkForkFound = true;
|
||||
SetfLargeWorkForkFound(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogPrintf("%s: Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.\n", __func__);
|
||||
fLargeWorkInvalidChainFound = true;
|
||||
SetfLargeWorkInvalidChainFound(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fLargeWorkForkFound = false;
|
||||
fLargeWorkInvalidChainFound = false;
|
||||
SetfLargeWorkForkFound(false);
|
||||
SetfLargeWorkInvalidChainFound(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1481,7 +1481,7 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uin
|
||||
/** Abort with a message */
|
||||
bool AbortNode(const std::string& strMessage, const std::string& userMessage="")
|
||||
{
|
||||
strMiscWarning = strMessage;
|
||||
SetMiscWarning(strMessage);
|
||||
LogPrintf("*** %s\n", strMessage);
|
||||
uiInterface.ThreadSafeMessageBox(
|
||||
userMessage.empty() ? _("Error: A fatal internal error occurred, see debug.log for details") : userMessage,
|
||||
@@ -2050,9 +2050,10 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
|
||||
ThresholdState state = checker.GetStateFor(pindex, chainParams.GetConsensus(), warningcache[bit]);
|
||||
if (state == THRESHOLD_ACTIVE || state == THRESHOLD_LOCKED_IN) {
|
||||
if (state == THRESHOLD_ACTIVE) {
|
||||
strMiscWarning = strprintf(_("Warning: unknown new rules activated (versionbit %i)"), bit);
|
||||
std::string strWarning = strprintf(_("Warning: unknown new rules activated (versionbit %i)"), bit);
|
||||
SetMiscWarning(strWarning);
|
||||
if (!fWarned) {
|
||||
AlertNotify(strMiscWarning);
|
||||
AlertNotify(strWarning);
|
||||
fWarned = true;
|
||||
}
|
||||
} else {
|
||||
@@ -2072,10 +2073,11 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
|
||||
warningMessages.push_back(strprintf("%d of last 100 blocks have unexpected version", nUpgraded));
|
||||
if (nUpgraded > 100/2)
|
||||
{
|
||||
// strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
|
||||
strMiscWarning = _("Warning: Unknown block versions being mined! It's possible unknown rules are in effect");
|
||||
std::string strWarning = _("Warning: Unknown block versions being mined! It's possible unknown rules are in effect");
|
||||
// notify GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
|
||||
SetMiscWarning(strWarning);
|
||||
if (!fWarned) {
|
||||
AlertNotify(strMiscWarning);
|
||||
AlertNotify(strWarning);
|
||||
fWarned = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user