From eef595560e9ecf3a0d1db4d8ea7ecc33a49d839f Mon Sep 17 00:00:00 2001 From: furszy Date: Thu, 7 Sep 2023 11:40:41 -0300 Subject: 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. --- src/index/coinstatsindex.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/index') diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp index d80885f842..30a4d52a34 100644 --- a/src/index/coinstatsindex.cpp +++ b/src/index/coinstatsindex.cpp @@ -288,7 +288,9 @@ bool CoinStatsIndex::CustomRewind(const interfaces::BlockKey& current_tip, const __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); } while (new_tip_index != iter_tip); -- cgit v1.2.3