diff --git a/eth/gasprice/gasprice.go b/eth/gasprice/gasprice.go index c8974c7e6..f6e9e3884 100644 --- a/eth/gasprice/gasprice.go +++ b/eth/gasprice/gasprice.go @@ -254,7 +254,8 @@ func (oracle *Oracle) getBlockPrices(ctx context.Context, blockNum uint64, limit txs := newTransactionsByGasPrice(plainTxs, baseFee) heap.Init(&txs) - for txs.Len() > 0 { + count := 0 + for count < limit && txs.Len() > 0 { tx := heap.Pop(&txs).(types.Transaction) tip := tx.GetEffectiveGasTip(baseFee) if ignoreUnder != nil && tip.Lt(ignoreUnder) { @@ -263,9 +264,7 @@ func (oracle *Oracle) getBlockPrices(ctx context.Context, blockNum uint64, limit sender, _ := tx.GetSender() if err == nil && sender != block.Coinbase() { heap.Push(s, tip) - if s.Len() >= limit { - break - } + count = count + 1 } } return nil