mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Merge #12988: Hold cs_main while calling UpdatedBlockTip() signal
d86edd3
Hold cs_main while calling UpdatedBlockTip() and ui.NotifyBlockTip (Jesse Cohen)
Pull request description:
Resolves #12978
Tree-SHA512: 2aed09434cd8dbf541ea75462070b73ee87ff31409bede210f6999ffee4a37e32202a289efd37609485d4cbdfe134fe4660a10bfb41e8a8acdba7cd0b61b8780
fix indentation
Signed-off-by: pasta <pasta@dashboost.org>
This commit is contained in:
parent
f70e8bebcd
commit
06aebf5eb0
@ -3069,12 +3069,9 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
|
|||||||
assert(trace.pblock && trace.pindex);
|
assert(trace.pblock && trace.pindex);
|
||||||
GetMainSignals().BlockConnected(trace.pblock, trace.pindex, trace.conflictedTxs);
|
GetMainSignals().BlockConnected(trace.pblock, trace.pindex, trace.conflictedTxs);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// When we reach this point, we switched to a new tip (stored in pindexNewTip).
|
|
||||||
|
|
||||||
// Notifications/callbacks that can run without cs_main
|
|
||||||
|
|
||||||
// Notify external listeners about the new tip.
|
// Notify external listeners about the new tip.
|
||||||
|
// Enqueue while holding cs_main to ensure that UpdatedBlockTip is called in the order in which blocks are connected
|
||||||
GetMainSignals().SynchronousUpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload);
|
GetMainSignals().SynchronousUpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload);
|
||||||
GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload);
|
GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload);
|
||||||
|
|
||||||
@ -3082,6 +3079,8 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
|
|||||||
if (pindexFork != pindexNewTip) {
|
if (pindexFork != pindexNewTip) {
|
||||||
uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip);
|
uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// When we reach this point, we switched to a new tip (stored in pindexNewTip).
|
||||||
|
|
||||||
if (nStopAtHeight && pindexNewTip && pindexNewTip->nHeight >= nStopAtHeight) StartShutdown();
|
if (nStopAtHeight && pindexNewTip && pindexNewTip->nHeight >= nStopAtHeight) StartShutdown();
|
||||||
|
|
||||||
|
@ -170,6 +170,10 @@ void CMainSignals::MempoolEntryRemoved(CTransactionRef ptx, MemPoolRemovalReason
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CMainSignals::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {
|
void CMainSignals::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {
|
||||||
|
// Dependencies exist that require UpdatedBlockTip events to be delivered in the order in which
|
||||||
|
// the chain actually updates. One way to ensure this is for the caller to invoke this signal
|
||||||
|
// in the same critical section where the chain is updated
|
||||||
|
|
||||||
m_internals->m_schedulerClient.AddToProcessQueue([pindexNew, pindexFork, fInitialDownload, this] {
|
m_internals->m_schedulerClient.AddToProcessQueue([pindexNew, pindexFork, fInitialDownload, this] {
|
||||||
m_internals->UpdatedBlockTip(pindexNew, pindexFork, fInitialDownload);
|
m_internals->UpdatedBlockTip(pindexNew, pindexFork, fInitialDownload);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user