Browse Source

Better warning/"alert" messages for large-work forks.

0.10
Matt Corallo 12 years ago
parent
commit
f65e7092a2
  1. 29
      src/main.cpp

29
src/main.cpp

@ -1384,6 +1384,7 @@ bool IsInitialBlockDownload()
} }
bool fLargeWorkForkFound = false; bool fLargeWorkForkFound = false;
bool fLargeWorkInvalidChainFound = false;
CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL; CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL;
void CheckForkWarningConditions() void CheckForkWarningConditions()
@ -1400,15 +1401,30 @@ void CheckForkWarningConditions()
std::string strCmd = GetArg("-alertnotify", ""); std::string strCmd = GetArg("-alertnotify", "");
if (!strCmd.empty()) if (!strCmd.empty())
{ {
std::string warning("'Warning: Large-work fork detected. You may need to upgrade, or other nodes may need to upgrade.'"); std::string warning = std::string("'Warning: Large-work fork detected, forking after block ") +
pindexBestForkBase->phashBlock->ToString() + std::string("'");
boost::replace_all(strCmd, "%s", warning); boost::replace_all(strCmd, "%s", warning);
boost::thread t(runCommand, strCmd); // thread runs free boost::thread t(runCommand, strCmd); // thread runs free
} }
} }
if (pindexBestForkTip)
{
printf("CheckForkWarningConditions: 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",
pindexBestForkBase->nHeight, pindexBestForkBase->phashBlock->ToString().c_str(),
pindexBestForkTip->nHeight, pindexBestForkTip->phashBlock->ToString().c_str());
fLargeWorkForkFound = true; fLargeWorkForkFound = true;
printf("CheckForkWarningConditions: Warning: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n"); }
} else else
{
printf("CheckForkWarningConditions: Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.\n");
fLargeWorkInvalidChainFound = true;
}
}
else
{
fLargeWorkForkFound = false; fLargeWorkForkFound = false;
fLargeWorkInvalidChainFound = false;
}
} }
void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip) void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip)
@ -3138,7 +3154,12 @@ string GetWarnings(string strFor)
if (fLargeWorkForkFound) if (fLargeWorkForkFound)
{ {
nPriority = 2000; nPriority = 2000;
strStatusBar = strRPC = _("Warning: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade."); strStatusBar = strRPC = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
}
else if (fLargeWorkInvalidChainFound)
{
nPriority = 2000;
strStatusBar = strRPC = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
} }
// Alerts // Alerts

Loading…
Cancel
Save