diff --git a/core/txpool/bundlepool/bundlepool.go b/core/txpool/bundlepool/bundlepool.go index a1b0e1a838..2a9f406d07 100644 --- a/core/txpool/bundlepool/bundlepool.go +++ b/core/txpool/bundlepool/bundlepool.go @@ -361,6 +361,12 @@ func (p *BundlePool) reset(newHead *types.Header) { p.mu.Lock() defer p.mu.Unlock() + if len(p.bundles) == 0 { + bundleGauge.Update(int64(len(p.bundles))) + slotsGauge.Update(int64(p.slots)) + return + } + // Prune outdated bundles and invalid bundles block := p.chain.GetBlock(newHead.Hash(), newHead.Number.Uint64()) txSet := mapset.NewSet[common.Hash]() @@ -370,6 +376,7 @@ func (p *BundlePool) reset(newHead *types.Header) { txSet.Add(tx.Hash()) } } + p.bundleHeap = make(BundleHeap, 0) for hash, bundle := range p.bundles { if (bundle.MaxTimestamp != 0 && newHead.Time > bundle.MaxTimestamp) || (bundle.MaxBlockNumber != 0 && newHead.Number.Cmp(new(big.Int).SetUint64(bundle.MaxBlockNumber)) > 0) { @@ -379,6 +386,9 @@ func (p *BundlePool) reset(newHead *types.Header) { p.slots -= numSlots(p.bundles[hash]) delete(p.bundles, hash) } + if p.bundles[hash] != nil { + p.bundleHeap.Push(bundle) + } } bundleGauge.Update(int64(len(p.bundles))) slotsGauge.Update(int64(p.slots))