Skip to content

Commit

Permalink
Merge pull request #434 from gcash/reorg-panic
Browse files Browse the repository at this point in the history
[Bug] Fix panic in fee estimator from reorgs
  • Loading branch information
cpacia committed Dec 9, 2020
2 parents 0e0e371 + 802eaea commit 175c1e8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mempool/estimatefee.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,10 @@ func (ef *FeeEstimator) RegisterBlock(block *bchutil.Block) error {
return errors.New("Transaction has already been mined")
}

// This shouldn't happen but check just in case to avoid
// an out-of-bounds array index later.
if blocksToConfirm >= estimateFeeDepth {
// This shouldn't happen in normal operation but check just in case
// to avoid an out-of-bounds array index later. Make sure to cover
// negative indexes in the case of reorgs.
if blocksToConfirm >= estimateFeeDepth || blocksToConfirm < 0 {
continue
}

Expand Down

0 comments on commit 175c1e8

Please sign in to comment.