mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge pull request #5059
dbca89bTrigger -alertnotify if network is upgrading without you (Gavin Andresen)e01a793Refactor -alertnotify code (Gavin Andresen) Signed-off-by: Gavin Andresen <gavinandresen@gmail.com>
This commit is contained in:
18
src/main.cpp
18
src/main.cpp
@@ -1178,14 +1178,9 @@ void CheckForkWarningConditions()
|
||||
{
|
||||
if (!fLargeWorkForkFound)
|
||||
{
|
||||
std::string strCmd = GetArg("-alertnotify", "");
|
||||
if (!strCmd.empty())
|
||||
{
|
||||
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::thread t(runCommand, strCmd); // thread runs free
|
||||
}
|
||||
std::string warning = std::string("'Warning: Large-work fork detected, forking after block ") +
|
||||
pindexBestForkBase->phashBlock->ToString() + std::string("'");
|
||||
CAlert::Notify(warning, true);
|
||||
}
|
||||
if (pindexBestForkTip)
|
||||
{
|
||||
@@ -1753,7 +1748,8 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
||||
cvBlockChange.notify_all();
|
||||
|
||||
// Check the version of the last 100 blocks to see if we need to upgrade:
|
||||
if (!IsInitialBlockDownload())
|
||||
static bool fWarned = false;
|
||||
if (!IsInitialBlockDownload() && !fWarned)
|
||||
{
|
||||
int nUpgraded = 0;
|
||||
const CBlockIndex* pindex = chainActive.Tip();
|
||||
@@ -1766,8 +1762,12 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
||||
if (nUpgraded > 0)
|
||||
LogPrintf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, (int)CBlock::CURRENT_VERSION);
|
||||
if (nUpgraded > 100/2)
|
||||
{
|
||||
// strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
|
||||
strMiscWarning = _("Warning: This version is obsolete, upgrade required!");
|
||||
CAlert::Notify(strMiscWarning, true);
|
||||
fWarned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user