mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-23 07:15:29 +01:00
index: Move last_locator_write_time and logging to end of threadsync loop
This avoids having commit print a needless error message during init. Co-authored-by: furszy <mfurszy@protonmail.com>
This commit is contained in:
parent
015ac13dcc
commit
f65b0f6401
1 changed files with 14 additions and 14 deletions
|
@ -177,20 +177,6 @@ void BaseIndex::ThreadSync()
|
|||
pindex = pindex_next;
|
||||
}
|
||||
|
||||
auto current_time{std::chrono::steady_clock::now()};
|
||||
if (last_log_time + SYNC_LOG_INTERVAL < current_time) {
|
||||
LogPrintf("Syncing %s with block chain from height %d\n",
|
||||
GetName(), pindex->nHeight);
|
||||
last_log_time = current_time;
|
||||
}
|
||||
|
||||
if (last_locator_write_time + SYNC_LOCATOR_WRITE_INTERVAL < current_time) {
|
||||
SetBestBlockIndex(pindex->pprev);
|
||||
last_locator_write_time = current_time;
|
||||
// No need to handle errors in Commit. See rationale above.
|
||||
Commit();
|
||||
}
|
||||
|
||||
CBlock block;
|
||||
interfaces::BlockInfo block_info = kernel::MakeBlockInfo(pindex);
|
||||
if (!m_chainstate->m_blockman.ReadBlockFromDisk(block, *pindex)) {
|
||||
|
@ -205,6 +191,20 @@ void BaseIndex::ThreadSync()
|
|||
__func__, pindex->GetBlockHash().ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
auto current_time{std::chrono::steady_clock::now()};
|
||||
if (last_log_time + SYNC_LOG_INTERVAL < current_time) {
|
||||
LogPrintf("Syncing %s with block chain from height %d\n",
|
||||
GetName(), pindex->nHeight);
|
||||
last_log_time = current_time;
|
||||
}
|
||||
|
||||
if (last_locator_write_time + SYNC_LOCATOR_WRITE_INTERVAL < current_time) {
|
||||
SetBestBlockIndex(pindex);
|
||||
last_locator_write_time = current_time;
|
||||
// No need to handle errors in Commit. See rationale above.
|
||||
Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue