index: coinstats reorg, fail when block cannot be reversed

During a reorg, continuing execution when a block cannot be
reversed leaves the coinstats index in an inconsistent state,
which was surely overlooked when 'CustomRewind' was implemented.
This commit is contained in:
furszy
2023-09-07 11:40:41 -03:00
parent 8e0d9796da
commit eef595560e

View File

@@ -288,7 +288,9 @@ bool CoinStatsIndex::CustomRewind(const interfaces::BlockKey& current_tip, const
__func__, iter_tip->GetBlockHash().ToString()); __func__, iter_tip->GetBlockHash().ToString());
} }
ReverseBlock(block, iter_tip); if (!ReverseBlock(block, iter_tip)) {
return false; // failure cause logged internally
}
iter_tip = iter_tip->GetAncestor(iter_tip->nHeight - 1); iter_tip = iter_tip->GetAncestor(iter_tip->nHeight - 1);
} while (new_tip_index != iter_tip); } while (new_tip_index != iter_tip);