@@ -177,20 +177,6 @@ void BaseIndex::ThreadSync()
177177 pindex = pindex_next;
178178 }
179179
180- auto current_time{std::chrono::steady_clock::now ()};
181- if (last_log_time + SYNC_LOG_INTERVAL < current_time) {
182- LogPrintf (" Syncing %s with block chain from height %d\n " ,
183- GetName (), pindex->nHeight );
184- last_log_time = current_time;
185- }
186-
187- if (last_locator_write_time + SYNC_LOCATOR_WRITE_INTERVAL < current_time) {
188- SetBestBlockIndex (pindex->pprev );
189- last_locator_write_time = current_time;
190- // No need to handle errors in Commit. See rationale above.
191- Commit ();
192- }
193-
194180 CBlock block;
195181 interfaces::BlockInfo block_info = kernel::MakeBlockInfo (pindex);
196182 if (!m_chainstate->m_blockman .ReadBlockFromDisk (block, *pindex)) {
@@ -205,6 +191,20 @@ void BaseIndex::ThreadSync()
205191 __func__, pindex->GetBlockHash ().ToString ());
206192 return ;
207193 }
194+
195+ auto current_time{std::chrono::steady_clock::now ()};
196+ if (last_log_time + SYNC_LOG_INTERVAL < current_time) {
197+ LogPrintf (" Syncing %s with block chain from height %d\n " ,
198+ GetName (), pindex->nHeight );
199+ last_log_time = current_time;
200+ }
201+
202+ if (last_locator_write_time + SYNC_LOCATOR_WRITE_INTERVAL < current_time) {
203+ SetBestBlockIndex (pindex);
204+ last_locator_write_time = current_time;
205+ // No need to handle errors in Commit. See rationale above.
206+ Commit ();
207+ }
208208 }
209209 }
210210
0 commit comments