Merge pull request #4599
This commit is contained in:
commit
309aa76d27
11
src/init.cpp
11
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))
|
||||
|
|
13
src/main.cpp
13
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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue