Skip to content

Commit bce5f37

Browse files
committed
[refactor] change ActiveTipChange to use CBlockIndex ref instead of ptr
1 parent 7cc5ac5 commit bce5f37

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/net_processing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ class PeerManagerImpl final : public PeerManager
489489
CTxMemPool& pool, node::Warnings& warnings, Options opts);
490490

491491
/** Overridden from CValidationInterface. */
492-
void ActiveTipChange(const CBlockIndex* new_tip, bool) override
492+
void ActiveTipChange(const CBlockIndex& new_tip, bool) override
493493
EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
494494
void BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override
495495
EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
@@ -2070,7 +2070,7 @@ void PeerManagerImpl::StartScheduledTasks(CScheduler& scheduler)
20702070
scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, delta);
20712071
}
20722072

2073-
void PeerManagerImpl::ActiveTipChange(const CBlockIndex* new_tip, bool is_ibd)
2073+
void PeerManagerImpl::ActiveTipChange(const CBlockIndex& new_tip, bool is_ibd)
20742074
{
20752075
AssertLockNotHeld(m_mempool.cs);
20762076
AssertLockNotHeld(m_tx_download_mutex);

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3553,7 +3553,7 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr<
35533553
} // release MempoolMutex
35543554
// Notify external listeners about the new tip, even if pindexFork == pindexNewTip.
35553555
if (m_chainman.m_options.signals && this == &m_chainman.ActiveChainstate()) {
3556-
m_chainman.m_options.signals->ActiveTipChange(pindexNewTip, m_chainman.IsInitialBlockDownload());
3556+
m_chainman.m_options.signals->ActiveTipChange(*Assert(pindexNewTip), m_chainman.IsInitialBlockDownload());
35573557
}
35583558
} // release cs_main
35593559
// When we reach this point, we switched to a new tip (stored in pindexNewTip).
@@ -3778,7 +3778,7 @@ bool Chainstate::InvalidateBlock(BlockValidationState& state, CBlockIndex* pinde
37783778
// Fire ActiveTipChange now for the current chain tip to make sure clients are notified.
37793779
// ActivateBestChain may call this as well, but not necessarily.
37803780
if (m_chainman.m_options.signals) {
3781-
m_chainman.m_options.signals->ActiveTipChange(m_chain.Tip(), m_chainman.IsInitialBlockDownload());
3781+
m_chainman.m_options.signals->ActiveTipChange(*Assert(m_chain.Tip()), m_chainman.IsInitialBlockDownload());
37823782
}
37833783
}
37843784
return true;

src/validationinterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ void ValidationSignals::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlo
183183
fInitialDownload);
184184
}
185185

186-
void ValidationSignals::ActiveTipChange(const CBlockIndex *new_tip, bool is_ibd)
186+
void ValidationSignals::ActiveTipChange(const CBlockIndex& new_tip, bool is_ibd)
187187
{
188-
LOG_EVENT("%s: new block hash=%s block height=%d", __func__, new_tip->GetBlockHash().ToString(), new_tip->nHeight);
188+
LOG_EVENT("%s: new block hash=%s block height=%d", __func__, new_tip.GetBlockHash().ToString(), new_tip.nHeight);
189189
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.ActiveTipChange(new_tip, is_ibd); });
190190
}
191191

src/validationinterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CValidationInterface {
6464
/**
6565
* Notifies listeners any time the block chain tip changes, synchronously.
6666
*/
67-
virtual void ActiveTipChange(const CBlockIndex* new_tip, bool is_ibd) {};
67+
virtual void ActiveTipChange(const CBlockIndex& new_tip, bool is_ibd) {};
6868
/**
6969
* Notifies listeners of a transaction having been added to mempool.
7070
*
@@ -218,7 +218,7 @@ class ValidationSignals {
218218
void SyncWithValidationInterfaceQueue() LOCKS_EXCLUDED(cs_main);
219219

220220
void UpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload);
221-
void ActiveTipChange(const CBlockIndex*, bool);
221+
void ActiveTipChange(const CBlockIndex&, bool);
222222
void TransactionAddedToMempool(const NewMempoolTransactionInfo&, uint64_t mempool_sequence);
223223
void TransactionRemovedFromMempool(const CTransactionRef&, MemPoolRemovalReason, uint64_t mempool_sequence);
224224
void MempoolTransactionsRemovedForBlock(const std::vector<RemovedMempoolTransactionInfo>&, unsigned int nBlockHeight);

0 commit comments

Comments
 (0)