0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

Merge bitcoin/bitcoin#27905: validation: add missing insert to m_dirty_blockindex

e639364495 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](f0758d8a66/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 e639364495
  stickies-v:
    ACK e639364495

Tree-SHA512: a97af9c173e31b90b677a1f95de822e08078d78013de5fa5fe4c3bec06f45d6e1823b7694cdacb887d031329e4b4afc6a2003916e0ae131279dee71f43e1f478
This commit is contained in:
fanquake 2023-06-21 13:27:54 +01:00
commit d23cdf659e
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -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