From 4fa5629f31caecd4dc9de826c6e5a58af9defe13 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Tue, 1 Oct 2024 18:30:57 +0700 Subject: [PATCH] implement DropAllTxs for blob pool --- core/txpool/blobpool/blobpool.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index 0352ea9783..838640fbf9 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -325,6 +325,26 @@ type BlobPool struct { lock sync.RWMutex // Mutex protecting the pool during reorg handling } +func (p *BlobPool) DropAllTxs() { + p.lock.Lock() + defer p.lock.Unlock() + + for _, entry := range p.lookup { + if err := p.store.Delete(entry); err != nil { + log.Warn("failed to delete blob tx from backing store", "err", err) + } + } + p.lookup = make(map[common.Hash]uint64) + p.index = make(map[common.Address][]*blobTxMeta) + p.spent = make(map[common.Address]*uint256.Int) + + var ( + basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), p.head)) + blobfee = uint256.NewInt(params.BlobTxMinBlobGasprice) + ) + p.evict = newPriceHeap(basefee, blobfee, p.index) +} + // New creates a new blob transaction pool to gather, sort and filter inbound // blob transactions from the network. func New(config Config, chain BlockChain) *BlobPool {