diff options
author | fanquake <fanquake@gmail.com> | 2022-05-19 14:00:06 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-05-19 14:00:22 +0100 |
commit | e18fd4763e77d1e19208effa9f1a08c5b29fea8e (patch) | |
tree | febe51df3ce14c93345bd3028c01943a0d7c510f /src | |
parent | 345d860f38188b1bb6dfb95cb47f8b4057455669 (diff) | |
parent | 7171ebc7cbd911fa7ccad732ea7f73bce30928ee (diff) | |
download | bitcoin-e18fd4763e77d1e19208effa9f1a08c5b29fea8e.tar.xz |
Merge bitcoin/bitcoin#25074: index: During sync, commit best block after indexing
7171ebc7cbd911fa7ccad732ea7f73bce30928ee 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 ACK 7171ebc7cbd911fa7ccad732ea7f73bce30928ee. Looks great! Just commit message changes since last review
Tree-SHA512: a008de511dd6a1731b7fdf6a90add48d1e53f7f7d6402672adb83e362677fc5b9f5cd021d3111728cb41d73f1b9c2140db79d7e183df0ab359cda8c01b0ef928
Diffstat (limited to 'src')
-rw-r--r-- | src/index/base.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/index/base.cpp b/src/index/base.cpp index a00ae13e5c..9f0c1dea24 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -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(); |