aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2014-08-14 12:32:34 -0400
committerJeff Garzik <jgarzik@bitpay.com>2014-08-14 12:32:34 -0400
commitc7b6117debf4ebabc464a55b840bdd7bdeb94fa3 (patch)
treef0a46587349bba3bb5ab0a3a01e589e9c8e18502 /src/init.cpp
parentbeb36e800c393da3c5857a8f1e5959748ac0f96b (diff)
Create new signal for notification of new blocks. Use w/ -blocknotify
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 8ae228bbbe..494342c693 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -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))