mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
Merge bitcoin/bitcoin#25074: index: During sync, commit best block after indexing
7171ebc7cb
index: Don't commit a best block before indexing it during sync (Martin Zumsande) Pull request description: This changes the periodic commit of the best block during the index sync phase to use the already indexed predecessor of the current block index, instead of committing the current one that will only be indexed (by calling `WriteBlock()`) after committing the best block. The previous code would leave the index database in an inconsistent state until the block is actually indexed - if an unclean shutdown happened at just this point in time, the index could get corrupted because at next startup, we'd assume that we have already indexed this block. ACKs for top commit: ryanofsky: Code review ACK7171ebc7cb
. Looks great! Just commit message changes since last review Tree-SHA512: a008de511dd6a1731b7fdf6a90add48d1e53f7f7d6402672adb83e362677fc5b9f5cd021d3111728cb41d73f1b9c2140db79d7e183df0ab359cda8c01b0ef928
This commit is contained in:
commit
e18fd4763e
@ -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…
Reference in New Issue
Block a user