@ -159,23 +159,20 @@ void BaseIndex::Sync()
return ;
}
{
LOCK ( cs_main ) ;
const CBlockIndex * pindex_next = NextSyncBlock ( pindex , m_chainstate - > m_chain ) ;
if ( ! pindex_next ) {
SetBestBlockIndex ( pindex ) ;
m_synced = true ;
// No need to handle errors in Commit. See rationale above.
Commit ( ) ;
break ;
}
if ( pindex_next - > pprev ! = pindex & & ! Rewind ( pindex , pindex_next - > pprev ) ) {
FatalErrorf ( " %s: Failed to rewind index %s to a previous chain tip " ,
__func__ , GetName ( ) ) ;
return ;
}
pindex = pindex_next ;
const CBlockIndex * pindex_next = WITH_LOCK ( cs_main , return NextSyncBlock ( pindex , m_chainstate - > m_chain ) ) ;
if ( ! pindex_next ) {
SetBestBlockIndex ( pindex ) ;
m_synced = true ;
// No need to handle errors in Commit. See rationale above.
Commit ( ) ;
break ;
}
if ( pindex_next - > pprev ! = pindex & & ! Rewind ( pindex , pindex_next - > pprev ) ) {
FatalErrorf ( " %s: Failed to rewind index %s to a previous chain tip " , __func__ , GetName ( ) ) ;
return ;
}
pindex = pindex_next ;
auto current_time { std : : chrono : : steady_clock : : now ( ) } ;
if ( last_log_time + SYNC_LOG_INTERVAL < current_time ) {