diff --git a/src/init.cpp b/src/init.cpp index c3a326841..21a566848 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -269,7 +270,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-?", _("This help message")); strUsage += HelpMessageOpt("-alerts", strprintf(_("Receive and display P2P network alerts (default: %u)"), DEFAULT_ALERTS)); strUsage += HelpMessageOpt("-alertnotify=", _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)")); - strUsage += HelpMessageOpt("-blocknotify=", _("Execute command when the best block changes (%s in cmd is replaced by block hash)")); + strUsage += HelpMessageOpt("-blocknotify=", _("Execute command when the best block changes (%s in cmd is replaced by block hash, %i is replaced by block number)")); strUsage += HelpMessageOpt("-checkblocks=", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), 288)); strUsage += HelpMessageOpt("-checklevel=", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), 3)); strUsage += HelpMessageOpt("-conf=", strprintf(_("Specify configuration file (default: %s)"), "bitcoin.conf")); @@ -452,11 +453,12 @@ std::string LicenseInfo() "\n"; } -static void BlockNotifyCallback(const uint256& hashNewTip) +static void BlockNotifyCallback(const uint256& hashNewTip, const int nHeight) { std::string strCmd = GetArg("-blocknotify", ""); boost::replace_all(strCmd, "%s", hashNewTip.GetHex()); + boost::replace_all(strCmd, "%i", boost::lexical_cast(chainActive.Height())); boost::thread t(runCommand, strCmd); // thread runs free } diff --git a/src/main.cpp b/src/main.cpp index 92d425ab8..8d408a34b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2424,7 +2424,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { pnode->PushInventory(CInv(MSG_BLOCK, hashNewTip)); } // Notify external listeners about the new tip. - uiInterface.NotifyBlockTip(hashNewTip); + uiInterface.NotifyBlockTip(hashNewTip, pindexNewTip->nHeight); } } while(pindexMostWork != chainActive.Tip()); CheckBlockIndex(); diff --git a/src/ui_interface.h b/src/ui_interface.h index 32a92a4b8..34ac7bf3b 100644 --- a/src/ui_interface.h +++ b/src/ui_interface.h @@ -94,7 +94,7 @@ public: boost::signals2::signal ShowProgress; /** New block has been accepted */ - boost::signals2::signal NotifyBlockTip; + boost::signals2::signal NotifyBlockTip; }; extern CClientUIInterface uiInterface;