Add block height to block notification substitution options

This commit is contained in:
Ross Nicoll 2015-08-11 19:27:05 +00:00
parent e0b0c0a84b
commit b668629143
3 changed files with 5 additions and 3 deletions

View file

@ -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>
@ -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
}

View file

@ -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();

View file

@ -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;