diff options
author | fanquake <fanquake@gmail.com> | 2023-06-21 13:27:54 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-06-21 13:40:28 +0100 |
commit | d23cdf659e147e7040a3924fc20cfaf639bbf5db (patch) | |
tree | 72c8be5641a4cd906a481c50a817949b52e0e2d7 | |
parent | e410fb711ccdcf828741ad3036210d7b8e8a9070 (diff) | |
parent | e639364495a26bd67dd08998fc7ec400747f9a15 (diff) |
Merge bitcoin/bitcoin#27905: validation: add missing insert to m_dirty_blockindex
e639364495a26bd67dd08998fc7ec400747f9a15 validation: add missing insert to m_dirty_blockindex (Martin Zumsande)
Pull request description:
When the status of a block index is changed, we must add it to `m_dirty_blockindex` or the change might not get persisted to disk.
This is missing from one spot in `FindMostWorkChain()`, where `BLOCK_FAILED_CHILD` is set.
Since we have [code](https://github.com/bitcoin/bitcoin/blob/f0758d8a6696657269d9c057e7aa079ffa9e1c16/src/node/blockstorage.cpp#L284-L287) that later sets missing `BLOCK_FAILED_CHILD` during the next startup, I don't think that this can lead to bad block indexes in practice, but I still think it's worth fixing.
ACKs for top commit:
TheCharlatan:
ACK e639364495a26bd67dd08998fc7ec400747f9a15
stickies-v:
ACK e639364495a26bd67dd08998fc7ec400747f9a15
Tree-SHA512: a97af9c173e31b90b677a1f95de822e08078d78013de5fa5fe4c3bec06f45d6e1823b7694cdacb887d031329e4b4afc6a2003916e0ae131279dee71f43e1f478
-rw-r--r-- | src/validation.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index d9a0fce34f..542c1060a9 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2914,6 +2914,7 @@ CBlockIndex* Chainstate::FindMostWorkChain() while (pindexTest != pindexFailed) { if (fFailedChain) { pindexFailed->nStatus |= BLOCK_FAILED_CHILD; + m_blockman.m_dirty_blockindex.insert(pindexFailed); } else if (fMissingData) { // If we're missing data, then add back to m_blocks_unlinked, // so that if the block arrives in the future we can try adding |