Browse Source

Call the -alertnotify script when we see a long or invalid fork.

tags/v0.15.1
Matt Corallo 8 years ago
parent
commit
f89faa2584
2 changed files with 11 additions and 1 deletions
  1. 1
    1
      src/init.cpp
  2. 10
    0
      src/main.cpp

+ 1
- 1
src/init.cpp View File

@@ -225,7 +225,7 @@ std::string HelpMessage()
strUsage += " -rpcthreads=<n> " + _("Set the number of threads to service RPC calls (default: 4)") + "\n";
strUsage += " -blocknotify=<cmd> " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n";
strUsage += " -walletnotify=<cmd> " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n";
strUsage += " -alertnotify=<cmd> " + _("Execute command when a relevant alert is received (%s in cmd is replaced by message)") + "\n";
strUsage += " -alertnotify=<cmd> " + _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)") + "\n";
strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + "\n";
strUsage += " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n";
strUsage += " -rescan " + _("Rescan the block chain for missing wallet transactions") + "\n";

+ 10
- 0
src/main.cpp View File

@@ -1395,6 +1395,16 @@ void CheckForkWarningConditions()

if (pindexBestForkTip || nBestInvalidWork > nBestChainWork + (pindexBest->GetBlockWork() * 6).getuint256())
{
if (!fLargeWorkForkFound)
{
std::string strCmd = GetArg("-alertnotify", "");
if (!strCmd.empty())
{
std::string warning("'Warning: Large-work fork detected. You may need to upgrade, or other nodes may need to upgrade.'");
boost::replace_all(strCmd, "%s", warning);
boost::thread t(runCommand, strCmd); // thread runs free
}
}
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

Loading…
Cancel
Save