Skip to content

Commit

Permalink
Add block height to block notification substitution options
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Nicoll committed Aug 11, 2015
1 parent e0b0c0a commit b668629
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/ui_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class CClientUIInterface
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;
Expand Down

0 comments on commit b668629

Please sign in to comment.