diff options
| author | Max K. <[email protected]> | 2015-08-13 18:41:49 +0200 |
|---|---|---|
| committer | Max K. <[email protected]> | 2015-08-13 18:41:49 +0200 |
| commit | 1027b821df35fbf2e7a05bfe39e0e9cdb90e9cd5 (patch) | |
| tree | e4a4c4b56f4c3ee6e207dded5d448c8f7d7c1ee6 /src | |
| parent | Merge pull request #1233 from patricklodder/1.10-travis-osx-sdk (diff) | |
| parent | advertise block height addition to -blocknotify (diff) | |
| download | discoin-1027b821df35fbf2e7a05bfe39e0e9cdb90e9cd5.tar.xz discoin-1027b821df35fbf2e7a05bfe39e0e9cdb90e9cd5.zip | |
Merge pull request #1238 from rnicoll/1.10-block-notify-height
Add block height to block notification
Diffstat (limited to 'src')
| -rw-r--r-- | src/init.cpp | 6 | ||||
| -rw-r--r-- | src/main.cpp | 2 | ||||
| -rw-r--r-- | src/ui_interface.h | 2 |
3 files changed, 6 insertions, 4 deletions
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 <boost/filesystem.hpp> #include <boost/function.hpp> #include <boost/interprocess/sync/file_lock.hpp> +#include <boost/lexical_cast.hpp> #include <boost/thread.hpp> #include <openssl/crypto.h> @@ -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=<cmd>", _("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=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)")); + strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash, %i is replaced by block number)")); strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), 288)); strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), 3)); strUsage += HelpMessageOpt("-conf=<file>", 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<std::string>(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<void (const std::string &title, int nProgress)> ShowProgress; /** New block has been accepted */ - boost::signals2::signal<void (const uint256& hash)> NotifyBlockTip; + boost::signals2::signal<void (const uint256& hash, const int nHeight)> NotifyBlockTip; }; extern CClientUIInterface uiInterface; |