From faf00f99e46292f14cd6018c59586d1c3241f8b8 Mon Sep 17 00:00:00 2001 From: hongdexiang <1090664234@qq.com> Date: Mon, 23 Dec 2024 16:50:57 +0800 Subject: [PATCH] feat: refine prune invalid bundle --- core/txpool/bundlepool/bundlepool.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/txpool/bundlepool/bundlepool.go b/core/txpool/bundlepool/bundlepool.go index 33d420b14..8076c663b 100644 --- a/core/txpool/bundlepool/bundlepool.go +++ b/core/txpool/bundlepool/bundlepool.go @@ -375,7 +375,8 @@ func (p *BundlePool) reset(newHead *types.Header) { (bundle.MaxBlockNumber != 0 && newHead.Number.Cmp(new(big.Int).SetUint64(bundle.MaxBlockNumber)) > 0) { p.slots -= numSlots(p.bundles[hash]) delete(p.bundles, hash) - } else if len(bundle.Txs) == 0 || txSet.Contains(bundle.Txs[0].Hash()) { + } else if len(bundle.Txs) == 0 || (txSet.Contains(bundle.Txs[0].Hash()) && + !containsHash(bundle.DroppingTxHashes, bundle.Txs[0].Hash())) { p.slots -= numSlots(p.bundles[hash]) delete(p.bundles, hash) } @@ -447,6 +448,15 @@ func numSlots(bundle *types.Bundle) uint64 { return (bundle.Size() + bundleSlotSize - 1) / bundleSlotSize } +func containsHash(arr []common.Hash, match common.Hash) bool { + for _, elem := range arr { + if elem == match { + return true + } + } + return false +} + // ===================================================================================================================== type BundleHeap []*types.Bundle