Skip to content

Commit 7e8d383

Browse files
fanquakevijaydasmp
authored andcommitted
Merge bitcoin#27905: validation: add missing insert to m_dirty_blockindex
e639364 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 e639364 stickies-v: ACK e639364 Tree-SHA512: a97af9c173e31b90b677a1f95de822e08078d78013de5fa5fe4c3bec06f45d6e1823b7694cdacb887d031329e4b4afc6a2003916e0ae131279dee71f43e1f478
1 parent 743ac80 commit 7e8d383

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/validation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,9 +3111,11 @@ CBlockIndex* CChainState::FindMostWorkChain()
31113111
while (pindexTest != pindexFailed) {
31123112
if (fFailedChain) {
31133113
pindexFailed->nStatus |= BLOCK_FAILED_CHILD;
3114+
m_blockman.m_dirty_blockindex.insert(pindexFailed);
31143115
} else if (fConflictingChain) {
31153116
// We don't need data for conflciting blocks
31163117
pindexFailed->nStatus |= BLOCK_CONFLICT_CHAINLOCK;
3118+
m_blockman.m_dirty_blockindex.insert(pindexFailed);
31173119
} else if (fMissingData) {
31183120
// If we're missing data, then add back to m_blocks_unlinked,
31193121
// so that if the block arrives in the future we can try adding

0 commit comments

Comments
 (0)