| 221 | } |
| 222 | |
| 223 | bool BaseIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_tip) |
| 224 | { |
| 225 | assert(current_tip == m_best_block_index); |
| 226 | assert(current_tip->GetAncestor(new_tip->nHeight) == new_tip); |
| 227 | |
| 228 | // In the case of a reorg, ensure persisted block locator is not stale. |
| 229 | // Pruning has a minimum of 288 blocks-to-keep and getting the index |
| 230 | // out of sync may be possible but a users fault. |
| 231 | // In case we reorg beyond the pruned depth, ReadBlockFromDisk would |
| 232 | // throw and lead to a graceful shutdown |
| 233 | m_best_block_index = new_tip; |
| 234 | if (!Commit()) { |
| 235 | // If commit fails, revert the best block index to avoid corruption. |
| 236 | m_best_block_index = current_tip; |
| 237 | return false; |
| 238 | } |
| 239 | |
| 240 | return true; |
| 241 | } |
| 242 | |
| 243 | void BaseIndex::BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) |
| 244 | { |
no test coverage detected