X Tutup
Skip to content

Commit 87e7d72

Browse files
committed
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.
1 parent a7e5cbb commit 87e7d72

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

src/main.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,11 +3099,9 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
30993099
}
31003100
});
31013101
}
3102-
// Notify external listeners about the new tip.
3103-
if (!vHashes.empty()) {
3104-
GetMainSignals().UpdatedBlockTip(pindexNewTip);
3105-
}
31063102
}
3103+
// Notify external listeners about the new tip.
3104+
GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload);
31073105
}
31083106
} while (pindexNewTip != pindexMostWork);
31093107
CheckBlockIndex(chainparams.GetConsensus());

src/validationinterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CMainSignals& GetMainSignals()
1313
}
1414

1515
void RegisterValidationInterface(CValidationInterface* pwalletIn) {
16-
g_signals.UpdatedBlockTip.connect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1));
16+
g_signals.UpdatedBlockTip.connect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1, _2, _3));
1717
g_signals.SyncTransaction.connect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2, _3));
1818
g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
1919
g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
@@ -33,7 +33,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
3333
g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
3434
g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
3535
g_signals.SyncTransaction.disconnect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2, _3));
36-
g_signals.UpdatedBlockTip.disconnect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1));
36+
g_signals.UpdatedBlockTip.disconnect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1, _2, _3));
3737
}
3838

3939
void UnregisterAllValidationInterfaces() {

src/validationinterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void SyncWithWallets(const CTransaction& tx, const CBlockIndex *pindex, int posI
3333

3434
class CValidationInterface {
3535
protected:
36-
virtual void UpdatedBlockTip(const CBlockIndex *pindex) {}
36+
virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {}
3737
virtual void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock) {}
3838
virtual void SetBestChain(const CBlockLocator &locator) {}
3939
virtual void UpdatedTransaction(const uint256 &hash) {}
@@ -49,7 +49,7 @@ class CValidationInterface {
4949

5050
struct CMainSignals {
5151
/** Notifies listeners of updated block chain tip */
52-
boost::signals2::signal<void (const CBlockIndex *)> UpdatedBlockTip;
52+
boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> UpdatedBlockTip;
5353
/** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
5454
boost::signals2::signal<void (const CTransaction &, const CBlockIndex *pindex, int posInBlock)> SyncTransaction;
5555
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */

src/zmq/zmqnotificationinterface.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,15 @@ void CZMQNotificationInterface::Shutdown()
124124
}
125125
}
126126

127-
void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindex)
127+
void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
128128
{
129+
if (fInitialDownload)
130+
return;
131+
129132
for (std::list<CZMQAbstractNotifier*>::iterator i = notifiers.begin(); i!=notifiers.end(); )
130133
{
131134
CZMQAbstractNotifier *notifier = *i;
132-
if (notifier->NotifyBlock(pindex))
135+
if (notifier->NotifyBlock(pindexNew))
133136
{
134137
i++;
135138
}

src/zmq/zmqnotificationinterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CZMQNotificationInterface : public CValidationInterface
2525

2626
// CValidationInterface
2727
void SyncTransaction(const CTransaction& tx, const CBlockIndex *pindex, int posInBlock);
28-
void UpdatedBlockTip(const CBlockIndex *pindex);
28+
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload);
2929

3030
private:
3131
CZMQNotificationInterface();

0 commit comments

Comments
 (0)
X Tutup