Create new signal for notification of new blocks. Use w/ -blocknotify

This commit is contained in:
Jeff Garzik
2014-08-14 12:32:34 -04:00
parent beb36e800c
commit c7b6117deb
3 changed files with 17 additions and 5 deletions

View File

@@ -367,6 +367,14 @@ std::string LicenseInfo()
"\n";
}
static void BlockNotifyCallback(const uint256& hashNewTip)
{
std::string strCmd = GetArg("-blocknotify", "");
boost::replace_all(strCmd, "%s", hashNewTip.GetHex());
boost::thread t(runCommand, strCmd); // thread runs free
}
struct CImportingNow
{
CImportingNow() {
@@ -1184,6 +1192,9 @@ bool AppInit2(boost::thread_group& threadGroup)
#endif // !ENABLE_WALLET
// ********************************************************* Step 9: import blocks
if (mapArgs.count("-blocknotify"))
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
// scan for better chains in the block chain database, that are not yet connected in the active best chain
CValidationState state;
if (!ActivateBestChain(state))