mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
Update alert notification and GUI
This commit is contained in:
28
src/main.cpp
28
src/main.cpp
@@ -1565,6 +1565,26 @@ bool fLargeWorkForkFound = false;
|
||||
bool fLargeWorkInvalidChainFound = false;
|
||||
CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL;
|
||||
|
||||
static void AlertNotify(const std::string& strMessage, bool fThread)
|
||||
{
|
||||
uiInterface.NotifyAlertChanged();
|
||||
std::string strCmd = GetArg("-alertnotify", "");
|
||||
if (strCmd.empty()) return;
|
||||
|
||||
// Alert text should be plain ascii coming from a trusted source, but to
|
||||
// be safe we first strip anything not in safeChars, then add single quotes around
|
||||
// the whole string before passing it to the shell:
|
||||
std::string singleQuote("'");
|
||||
std::string safeStatus = SanitizeString(strMessage);
|
||||
safeStatus = singleQuote+safeStatus+singleQuote;
|
||||
boost::replace_all(strCmd, "%s", safeStatus);
|
||||
|
||||
if (fThread)
|
||||
boost::thread t(runCommand, strCmd); // thread runs free
|
||||
else
|
||||
runCommand(strCmd);
|
||||
}
|
||||
|
||||
void CheckForkWarningConditions()
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
@@ -1584,7 +1604,7 @@ void CheckForkWarningConditions()
|
||||
{
|
||||
std::string warning = std::string("'Warning: Large-work fork detected, forking after block ") +
|
||||
pindexBestForkBase->phashBlock->ToString() + std::string("'");
|
||||
CAlert::Notify(warning, true);
|
||||
AlertNotify(warning, true);
|
||||
}
|
||||
if (pindexBestForkTip && pindexBestForkBase)
|
||||
{
|
||||
@@ -2115,7 +2135,7 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const
|
||||
if (!strWarning.empty())
|
||||
{
|
||||
strMiscWarning = strWarning;
|
||||
CAlert::Notify(strWarning, true);
|
||||
AlertNotify(strWarning, true);
|
||||
lastAlertTime = now;
|
||||
}
|
||||
}
|
||||
@@ -2545,7 +2565,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
||||
if (state == THRESHOLD_ACTIVE) {
|
||||
strMiscWarning = strprintf(_("Warning: unknown new rules activated (versionbit %i)"), bit);
|
||||
if (!fWarned) {
|
||||
CAlert::Notify(strMiscWarning, true);
|
||||
AlertNotify(strMiscWarning, true);
|
||||
fWarned = true;
|
||||
}
|
||||
} else {
|
||||
@@ -2567,7 +2587,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
||||
// 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");
|
||||
if (!fWarned) {
|
||||
CAlert::Notify(strMiscWarning, true);
|
||||
AlertNotify(strMiscWarning, true);
|
||||
fWarned = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user