diff options
author | Martin Zumsande <mzumsande@gmail.com> | 2022-01-20 22:21:56 +0100 |
---|---|---|
committer | Martin Zumsande <mzumsande@gmail.com> | 2022-01-31 21:20:41 +0100 |
commit | 0243907faee0aa6af09974131d9a46a7f9c3ef38 (patch) | |
tree | 4f8e99e6628dbaf5bdb5b0187b2bbb8ba190f0e2 /src/index/base.cpp | |
parent | 8f137e69caeb2a2ffe1aa930bd6fbc49cee4087c (diff) | |
download | bitcoin-0243907faee0aa6af09974131d9a46a7f9c3ef38.tar.xz |
index: Don't commit without valid m_best_block_index
Also report an error when coinstatsindex init fails.
Diffstat (limited to 'src/index/base.cpp')
-rw-r--r-- | src/index/base.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/index/base.cpp b/src/index/base.cpp index 2e3d500cd1..8fe30f8960 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -211,6 +211,11 @@ bool BaseIndex::Commit() bool BaseIndex::CommitInternal(CDBBatch& batch) { LOCK(cs_main); + // Don't commit anything if we haven't indexed any block yet + // (this could happen if init is interrupted). + if (m_best_block_index == nullptr) { + return false; + } GetDB().WriteBestBlock(batch, m_chainstate->m_chain.GetLocator(m_best_block_index)); return true; } |