Skip to content

Commit

Permalink
fix: concurrent map read in bundlepool
Browse files Browse the repository at this point in the history
  • Loading branch information
irrun committed Jan 15, 2025
1 parent fadd748 commit 1e8198b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/txpool/bundlepool/bundlepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ func (p *BundlePool) AddBundle(bundle *types.Bundle) error {
return err
}
bundle.Price = price

hash := bundle.Hash()

p.mu.Lock()
if _, ok := p.bundles[hash]; ok {
return ErrBundleAlreadyExist
}
Expand All @@ -162,17 +163,16 @@ func (p *BundlePool) AddBundle(bundle *types.Bundle) error {
return ErrBundleGasPriceLow
}

p.mu.Lock()
for p.slots+numSlots(bundle) > p.config.GlobalSlots {
p.drop()
}
p.bundles[hash] = bundle
heap.Push(&p.bundleHeap, bundle)
p.slots += numSlots(bundle)
p.mu.Unlock()

bundleGauge.Update(int64(len(p.bundles)))
slotsGauge.Update(int64(p.slots))
p.mu.Unlock()

p.bundleMetricsMu.Lock()
currentHeaderNumber := p.blockchain.CurrentBlock().Number.Int64()
Expand Down

0 comments on commit 1e8198b

Please sign in to comment.