Skip to content

Commit

Permalink
index: coinstats reorg, fail when block cannot be reversed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
furszy committed Sep 7, 2023
1 parent 8e0d979 commit eef5955
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index/coinstatsindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit eef5955

Please sign in to comment.