| 3719 | } |
| 3720 | |
| 3721 | void Chainstate::ResetBlockFailureFlags(CBlockIndex *pindex) { |
| 3722 | AssertLockHeld(cs_main); |
| 3723 | |
| 3724 | int nHeight = pindex->nHeight; |
| 3725 | |
| 3726 | // Remove the invalidity flag from this block and all its descendants and ancestors. |
| 3727 | for (auto& [_, block_index] : m_blockman.m_block_index) { |
| 3728 | if ((block_index.nStatus & BLOCK_FAILED_VALID) && (block_index.GetAncestor(nHeight) == pindex || pindex->GetAncestor(block_index.nHeight) == &block_index)) { |
| 3729 | block_index.nStatus &= ~BLOCK_FAILED_VALID; |
| 3730 | m_blockman.m_dirty_blockindex.insert(&block_index); |
| 3731 | if (block_index.IsValid(BLOCK_VALID_TRANSACTIONS) && block_index.HaveNumChainTxs() && setBlockIndexCandidates.value_comp()(m_chain.Tip(), &block_index)) { |
| 3732 | setBlockIndexCandidates.insert(&block_index); |
| 3733 | } |
| 3734 | if (&block_index == m_chainman.m_best_invalid) { |
| 3735 | // Reset invalid block marker if it was pointing to one of those. |
| 3736 | m_chainman.m_best_invalid = nullptr; |
| 3737 | } |
| 3738 | } |
| 3739 | } |
| 3740 | } |
| 3741 | |
| 3742 | void Chainstate::TryAddBlockIndexCandidate(CBlockIndex* pindex) |
| 3743 | { |