mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
index: Don't commit a best block before indexing it during sync
Committing a block prior to indexing would leave the index database in an inconsistent state until it is indexed, which could corrupt the index in case of a unclean shutdown. Thus commit its predecessor. Co-authored-by: Luke Dashjr <luke-jr+git@utopios.org>
This commit is contained in:
parent
59ac8bacd5
commit
7171ebc7cb
1 changed files with 1 additions and 1 deletions
|
@ -168,7 +168,7 @@ void BaseIndex::ThreadSync()
|
|||
}
|
||||
|
||||
if (last_locator_write_time + SYNC_LOCATOR_WRITE_INTERVAL < current_time) {
|
||||
SetBestBlockIndex(pindex);
|
||||
SetBestBlockIndex(pindex->pprev);
|
||||
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