Skip to content

Commit

Permalink
feat: refine prune invalid bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Lredhdx committed Dec 23, 2024
1 parent 7012e8a commit faf00f9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/txpool/bundlepool/bundlepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit faf00f9

Please sign in to comment.