Skip to content

Commit 5624e05

Browse files
author
João Barbosa
committed
Add UpdatedBlockTip signal to CMainSignals and CValidationInterface
1 parent 9733bc9 commit 5624e05

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,6 +2303,7 @@ bool ActivateBestChain(CValidationState &state, const CBlock *pblock) {
23032303
pnode->PushInventory(CInv(MSG_BLOCK, hashNewTip));
23042304
}
23052305
// Notify external listeners about the new tip.
2306+
GetMainSignals().UpdatedBlockTip(hashNewTip);
23062307
uiInterface.NotifyBlockTip(hashNewTip);
23072308
}
23082309
} while(pindexMostWork != chainActive.Tip());

src/validationinterface.cpp

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

1515
void RegisterValidationInterface(CValidationInterface* pwalletIn) {
16+
g_signals.UpdatedBlockTip.connect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1));
1617
g_signals.SyncTransaction.connect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2));
1718
g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
1819
g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
@@ -32,6 +33,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
3233
g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
3334
g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
3435
g_signals.SyncTransaction.disconnect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2));
36+
g_signals.UpdatedBlockTip.disconnect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1));
3537
}
3638

3739
void UnregisterAllValidationInterfaces() {
@@ -43,6 +45,8 @@ void UnregisterAllValidationInterfaces() {
4345
g_signals.SetBestChain.disconnect_all_slots();
4446
g_signals.UpdatedTransaction.disconnect_all_slots();
4547
g_signals.SyncTransaction.disconnect_all_slots();
48+
g_signals.UpdatedTransaction.disconnect_all_slots();
49+
g_signals.UpdatedBlockTip.disconnect_all_slots();
4650
}
4751

4852
void SyncWithWallets(const CTransaction &tx, const CBlock *pblock) {

src/validationinterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL);
3030

3131
class CValidationInterface {
3232
protected:
33+
virtual void UpdatedBlockTip(const uint256 &newHashTip) {}
3334
virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) {}
3435
virtual void SetBestChain(const CBlockLocator &locator) {}
3536
virtual void UpdatedTransaction(const uint256 &hash) {}
@@ -44,6 +45,8 @@ class CValidationInterface {
4445
};
4546

4647
struct CMainSignals {
48+
/** Notifies listeners of updated block chain tip */
49+
boost::signals2::signal<void (const uint256 &)> UpdatedBlockTip;
4750
/** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
4851
boost::signals2::signal<void (const CTransaction &, const CBlock *)> SyncTransaction;
4952
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */

0 commit comments

Comments
 (0)