Browse Source

Make validationinterface.UpdatedBlockTip more verbose

In anticipation of making all the callbacks out of block processing
flow through it. Note that vHashes will always have something in it
since pindexFork != pindexNewTip.
0.14
Matt Corallo 8 years ago
parent
commit
87e7d72807
  1. 6
      src/main.cpp
  2. 4
      src/validationinterface.cpp
  3. 4
      src/validationinterface.h
  4. 7
      src/zmq/zmqnotificationinterface.cpp
  5. 2
      src/zmq/zmqnotificationinterface.h

6
src/main.cpp

@ -3099,11 +3099,9 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, @@ -3099,11 +3099,9 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
}
});
}
// Notify external listeners about the new tip.
if (!vHashes.empty()) {
GetMainSignals().UpdatedBlockTip(pindexNewTip);
}
}
// Notify external listeners about the new tip.
GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload);
}
} while (pindexNewTip != pindexMostWork);
CheckBlockIndex(chainparams.GetConsensus());

4
src/validationinterface.cpp

@ -13,7 +13,7 @@ CMainSignals& GetMainSignals() @@ -13,7 +13,7 @@ CMainSignals& GetMainSignals()
}
void RegisterValidationInterface(CValidationInterface* pwalletIn) {
g_signals.UpdatedBlockTip.connect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1));
g_signals.UpdatedBlockTip.connect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1, _2, _3));
g_signals.SyncTransaction.connect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2, _3));
g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
@ -33,7 +33,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) { @@ -33,7 +33,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
g_signals.SyncTransaction.disconnect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2, _3));
g_signals.UpdatedBlockTip.disconnect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1));
g_signals.UpdatedBlockTip.disconnect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1, _2, _3));
}
void UnregisterAllValidationInterfaces() {

4
src/validationinterface.h

@ -33,7 +33,7 @@ void SyncWithWallets(const CTransaction& tx, const CBlockIndex *pindex, int posI @@ -33,7 +33,7 @@ void SyncWithWallets(const CTransaction& tx, const CBlockIndex *pindex, int posI
class CValidationInterface {
protected:
virtual void UpdatedBlockTip(const CBlockIndex *pindex) {}
virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {}
virtual void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock) {}
virtual void SetBestChain(const CBlockLocator &locator) {}
virtual void UpdatedTransaction(const uint256 &hash) {}
@ -49,7 +49,7 @@ protected: @@ -49,7 +49,7 @@ protected:
struct CMainSignals {
/** Notifies listeners of updated block chain tip */
boost::signals2::signal<void (const CBlockIndex *)> UpdatedBlockTip;
boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> UpdatedBlockTip;
/** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
boost::signals2::signal<void (const CTransaction &, const CBlockIndex *pindex, int posInBlock)> SyncTransaction;
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */

7
src/zmq/zmqnotificationinterface.cpp

@ -124,12 +124,15 @@ void CZMQNotificationInterface::Shutdown() @@ -124,12 +124,15 @@ void CZMQNotificationInterface::Shutdown()
}
}
void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindex)
void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
{
if (fInitialDownload)
return;
for (std::list<CZMQAbstractNotifier*>::iterator i = notifiers.begin(); i!=notifiers.end(); )
{
CZMQAbstractNotifier *notifier = *i;
if (notifier->NotifyBlock(pindex))
if (notifier->NotifyBlock(pindexNew))
{
i++;
}

2
src/zmq/zmqnotificationinterface.h

@ -25,7 +25,7 @@ protected: @@ -25,7 +25,7 @@ protected:
// CValidationInterface
void SyncTransaction(const CTransaction& tx, const CBlockIndex *pindex, int posInBlock);
void UpdatedBlockTip(const CBlockIndex *pindex);
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload);
private:
CZMQNotificationInterface();

Loading…
Cancel
Save