diff options
author | Martin Zumsande <mzumsande@gmail.com> | 2022-05-06 14:07:51 +0200 |
---|---|---|
committer | Martin Zumsande <mzumsande@gmail.com> | 2022-05-19 13:20:55 +0200 |
commit | 7171ebc7cbd911fa7ccad732ea7f73bce30928ee (patch) | |
tree | 1fcac72e8b75fbf0cd3e34dd0a25b2b33cf17099 /src/index/base.cpp | |
parent | 59ac8bacd573891d84e8ab96ff43ea12bd266f26 (diff) | |
download | bitcoin-7171ebc7cbd911fa7ccad732ea7f73bce30928ee.tar.xz |
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>
Diffstat (limited to 'src/index/base.cpp')
-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 f3c9395928..09f76adad9 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(); |