@@ -3405,24 +3405,24 @@ static SynchronizationState GetSynchronizationState(bool init, bool blockfiles_i
3405
3405
return SynchronizationState::INIT_DOWNLOAD;
3406
3406
}
3407
3407
3408
- static bool NotifyHeaderTip (ChainstateManager& chainman) LOCKS_EXCLUDED(cs_main )
3408
+ bool ChainstateManager:: NotifyHeaderTip ()
3409
3409
{
3410
3410
bool fNotify = false ;
3411
3411
bool fInitialBlockDownload = false ;
3412
3412
CBlockIndex* pindexHeader = nullptr ;
3413
3413
{
3414
- LOCK (cs_main );
3415
- pindexHeader = chainman. m_best_header ;
3414
+ LOCK (GetMutex () );
3415
+ pindexHeader = m_best_header;
3416
3416
3417
- if (pindexHeader != chainman. m_last_notified_header ) {
3417
+ if (pindexHeader != m_last_notified_header) {
3418
3418
fNotify = true ;
3419
- fInitialBlockDownload = chainman. IsInitialBlockDownload ();
3420
- chainman. m_last_notified_header = pindexHeader;
3419
+ fInitialBlockDownload = IsInitialBlockDownload ();
3420
+ m_last_notified_header = pindexHeader;
3421
3421
}
3422
3422
}
3423
- // Send block tip changed notifications without cs_main
3423
+ // Send block tip changed notifications without the lock held
3424
3424
if (fNotify ) {
3425
- chainman. GetNotifications ().headerTip (GetSynchronizationState (fInitialBlockDownload , chainman. m_blockman .m_blockfiles_indexed ), pindexHeader->nHeight , pindexHeader->nTime , false );
3425
+ GetNotifications ().headerTip (GetSynchronizationState (fInitialBlockDownload , m_blockman.m_blockfiles_indexed ), pindexHeader->nHeight , pindexHeader->nTime , false );
3426
3426
}
3427
3427
return fNotify ;
3428
3428
}
@@ -4378,7 +4378,7 @@ bool ChainstateManager::ProcessNewBlockHeaders(const std::vector<CBlockHeader>&
4378
4378
}
4379
4379
}
4380
4380
}
4381
- if (NotifyHeaderTip (* this )) {
4381
+ if (NotifyHeaderTip ()) {
4382
4382
if (IsInitialBlockDownload () && ppindex && *ppindex) {
4383
4383
const CBlockIndex& last_accepted{**ppindex};
4384
4384
int64_t blocks_left{(NodeClock::now () - last_accepted.Time ()) / GetConsensus ().PowTargetSpacing ()};
@@ -4549,7 +4549,7 @@ bool ChainstateManager::ProcessNewBlock(const std::shared_ptr<const CBlock>& blo
4549
4549
}
4550
4550
}
4551
4551
4552
- NotifyHeaderTip (* this );
4552
+ NotifyHeaderTip ();
4553
4553
4554
4554
BlockValidationState state; // Only used to report errors, not invalidity - ignore it
4555
4555
if (!ActiveChainstate ().ActivateBestChain (state, block)) {
@@ -5126,7 +5126,7 @@ void ChainstateManager::LoadExternalBlockFile(
5126
5126
}
5127
5127
}
5128
5128
5129
- NotifyHeaderTip (* this );
5129
+ NotifyHeaderTip ();
5130
5130
5131
5131
if (!blocks_with_unknown_parent) continue ;
5132
5132
@@ -5152,7 +5152,7 @@ void ChainstateManager::LoadExternalBlockFile(
5152
5152
}
5153
5153
range.first ++;
5154
5154
blocks_with_unknown_parent->erase (it);
5155
- NotifyHeaderTip (* this );
5155
+ NotifyHeaderTip ();
5156
5156
}
5157
5157
}
5158
5158
} catch (const std::exception& e) {
0 commit comments