diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-04-17 16:00:44 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-04-17 16:01:12 +0200 |
commit | 39e0c65b29eb2ba1e9bb29a38df59e8bc2b83585 (patch) | |
tree | 25f393c33285ba90994a066d7adf237e6ad32296 /src/validation.cpp | |
parent | 434150aef798321834937d170f0fdc9add4ebc79 (diff) | |
parent | d86edd3d3093be4c00d2c6a6fde6dfa77e2f4855 (diff) |
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
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 958c187220..3726cb3b14 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -354,7 +354,7 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp, bool CBlockIndex* tip = chainActive.Tip(); assert(tip != nullptr); - + CBlockIndex index; index.pprev = tip; // CheckSequenceLocks() uses chainActive.Height()+1 to evaluate @@ -2678,18 +2678,17 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams& assert(trace.pblock && trace.pindex); 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. + // Enqueue while holding cs_main to ensure that UpdatedBlockTip is called in the order in which blocks are connected + GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload); - // Notify external listeners about the new tip. - GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, fInitialDownload); - - // Always notify the UI if a new block tip was connected - if (pindexFork != pindexNewTip) { - uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip); + // Always notify the UI if a new block tip was connected + if (pindexFork != 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(); |