Skip to content

Commit

Permalink
Merge pull request #11 from kcalvinalvin/fix-node-crash-bug
Browse files Browse the repository at this point in the history
mempool/estimatefee: Fix negative index bug
  • Loading branch information
kcalvinalvin committed Dec 22, 2021
2 parents 34c1e42 + abb6094 commit e5d5bdc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mempool/estimatefee.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,16 @@ func (ef *FeeEstimator) RegisterBlock(block *btcutil.Block) error {

// This shouldn't happen but check just in case to avoid
// an out-of-bounds array index later.
if blocksToConfirm >= estimateFeeDepth {
//
// Also check that blocksToConfirm is not negative as this causes
// the node to crash on reorgs. A tx that was observed at height X
// might be included in heights less than X because of chain reorgs.
// Refer to github.com/btcsuite/btcd/issues/1660 for more information.
//
// TODO(kcalvinalvin) a better design that doesn't just skip over the
// transaction would result in a more accurate fee estimator. Properly
// implement this later.
if blocksToConfirm >= estimateFeeDepth || blocksToConfirm < 0 {
continue
}

Expand Down

0 comments on commit e5d5bdc

Please sign in to comment.