| 3047 | } |
| 3048 | |
| 3049 | void CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) { |
| 3050 | AssertLockHeld(cs_main); |
| 3051 | |
| 3052 | // In case we are reconsidering something before the finalization point, |
| 3053 | // move the finalization point to the last common ancestor. |
| 3054 | if (pindexFinalized) { |
| 3055 | pindexFinalized = LastCommonAncestor(pindex, pindexFinalized); |
| 3056 | } |
| 3057 | |
| 3058 | int nHeight = pindex->nHeight; |
| 3059 | |
| 3060 | // Remove the invalidity flag from this block and all its descendants. |
| 3061 | BlockMap::iterator it = mapBlockIndex.begin(); |
| 3062 | while (it != mapBlockIndex.end()) { |
| 3063 | if (!it->second->IsValid() && it->second->GetAncestor(nHeight) == pindex) { |
| 3064 | it->second->nStatus &= ~BLOCK_FAILED_MASK; |
| 3065 | setDirtyBlockIndex.insert(it->second); |
| 3066 | if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && it->second->nChainTx && setBlockIndexCandidates.value_comp()(chainActive.Tip(), it->second)) { |
| 3067 | setBlockIndexCandidates.insert(it->second); |
| 3068 | } |
| 3069 | if (it->second == pindexBestInvalid) { |
| 3070 | // Reset invalid block marker if it was pointing to one of those. |
| 3071 | pindexBestInvalid = nullptr; |
| 3072 | } |
| 3073 | m_failed_blocks.erase(it->second); |
| 3074 | } |
| 3075 | it++; |
| 3076 | } |
| 3077 | |
| 3078 | // Remove the invalidity flag from all ancestors too. |
| 3079 | while (pindex != nullptr) { |
| 3080 | if (pindex->nStatus & BLOCK_FAILED_MASK) { |
| 3081 | pindex->nStatus &= ~BLOCK_FAILED_MASK; |
| 3082 | setDirtyBlockIndex.insert(pindex); |
| 3083 | m_failed_blocks.erase(pindex); |
| 3084 | } |
| 3085 | pindex = pindex->pprev; |
| 3086 | } |
| 3087 | } |
| 3088 | |
| 3089 | void ResetBlockFailureFlags(CBlockIndex *pindex) { |
| 3090 | return g_chainstate.ResetBlockFailureFlags(pindex); |
no test coverage detected