diff options
author | Jeff Garzik <jgarzik@bitpay.com> | 2014-08-29 15:23:13 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@bitpay.com> | 2014-08-29 15:23:13 -0400 |
commit | 309aa76d279d2986b8d5a3756a38380c97107db7 (patch) | |
tree | 3a3b49819669e27d6b76d7b3d99b99c3b802505c /src | |
parent | 539abc4729ea16039d148cfa3b771929f7d37584 (diff) | |
parent | c7b6117debf4ebabc464a55b840bdd7bdeb94fa3 (diff) |
Merge pull request #4599
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 11 | ||||
-rw-r--r-- | src/main.cpp | 13 | ||||
-rw-r--r-- | src/qt/clientmodel.cpp | 8 | ||||
-rw-r--r-- | src/ui_interface.h | 6 |
4 files changed, 18 insertions, 20 deletions
diff --git a/src/init.cpp b/src/init.cpp index e972413c4b..c49083c7df 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -369,6 +369,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() { @@ -1185,6 +1193,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)) diff --git a/src/main.cpp b/src/main.cpp index ddc37ea534..81989d7faf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1387,10 +1387,8 @@ void Misbehaving(NodeId pnode, int howmuch) void static InvalidChainFound(CBlockIndex* pindexNew) { if (!pindexBestInvalid || pindexNew->nChainWork > pindexBestInvalid->nChainWork) - { pindexBestInvalid = pindexNew; - uiInterface.NotifyBlocksChanged(); - } + LogPrintf("InvalidChainFound: invalid block=%s height=%d log2_work=%.8g date=%s\n", pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, log(pindexNew->nChainWork.getdouble())/log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", @@ -2151,18 +2149,15 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { uint256 hashNewTip = pindexNewTip->GetBlockHash(); // Relay inventory, but don't relay old inventory during initial block download. int nBlockEstimate = Checkpoints::GetTotalBlocksEstimate(); + { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) if (chainActive.Height() > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) pnode->PushInventory(CInv(MSG_BLOCK, hashNewTip)); - - std::string strCmd = GetArg("-blocknotify", ""); - if (!strCmd.empty()) { - boost::replace_all(strCmd, "%s", hashNewTip.GetHex()); - boost::thread t(runCommand, strCmd); // thread runs free } + + uiInterface.NotifyBlockTip(hashNewTip); } - uiInterface.NotifyBlocksChanged(); } while(pindexMostWork != chainActive.Tip()); return true; diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 9c9ff5b3a1..738fb48ef8 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -209,12 +209,6 @@ static void ShowProgress(ClientModel *clientmodel, const std::string &title, int Q_ARG(int, nProgress)); } -static void NotifyBlocksChanged(ClientModel *clientmodel) -{ - // This notification is too frequent. Don't trigger a signal. - // Don't remove it, though, as it might be useful later. -} - static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConnections) { // Too noisy: qDebug() << "NotifyNumConnectionsChanged : " + QString::number(newNumConnections); @@ -234,7 +228,6 @@ void ClientModel::subscribeToCoreSignals() { // Connect signals to client uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2)); - uiInterface.NotifyBlocksChanged.connect(boost::bind(NotifyBlocksChanged, this)); uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1)); uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2)); } @@ -243,7 +236,6 @@ void ClientModel::unsubscribeFromCoreSignals() { // Disconnect signals from client uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2)); - uiInterface.NotifyBlocksChanged.disconnect(boost::bind(NotifyBlocksChanged, this)); uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1)); uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2)); } diff --git a/src/ui_interface.h b/src/ui_interface.h index b3df2b5a85..bbc8a203c9 100644 --- a/src/ui_interface.h +++ b/src/ui_interface.h @@ -78,9 +78,6 @@ public: /** Translate a message to the native language of the user. */ boost::signals2::signal<std::string (const char* psz)> Translate; - /** Block chain changed. */ - boost::signals2::signal<void ()> NotifyBlocksChanged; - /** Number of network connections changed. */ boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged; @@ -95,6 +92,9 @@ public: /** Show progress e.g. for verifychain */ boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress; + + /** New block has been accepted */ + boost::signals2::signal<void (const uint256& hash)> NotifyBlockTip; }; extern CClientUIInterface uiInterface; |