Skip to content

Commit

Permalink
fix: a nil pointer when query bundle price (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
irrun committed May 15, 2024
1 parent b467bae commit 0939f04
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,19 @@ func (b *EthAPIBackend) SendBundle(ctx context.Context, bundle *types.Bundle) er

func (b *EthAPIBackend) BundlePrice() *big.Int {
bundles := b.eth.txPool.AllBundles()
gasFloor := big.NewInt(b.eth.config.Miner.MevGasPriceFloor)

if len(bundles) == 0 {
return gasFloor
}

sort.SliceStable(bundles, func(i, j int) bool {
return bundles[j].Price.Cmp(bundles[i].Price) < 0
})

gasFloor := big.NewInt(b.eth.config.Miner.MevGasPriceFloor)
idx := len(bundles) / 2
if bundles[idx].Price.Cmp(gasFloor) < 0 {

if bundles[idx] == nil || bundles[idx].Price.Cmp(gasFloor) < 0 {
return gasFloor
}

Expand Down

0 comments on commit 0939f04

Please sign in to comment.