simplify blobpool

This commit is contained in:
maskpp 2024-09-17 15:57:14 +08:00
parent 8dd296201d
commit d5636a0ca7

View file

@ -1030,23 +1030,15 @@ func (p *BlobPool) SetGasTip(tip *big.Int) {
if tx.execTipCap.Cmp(p.gasTip) < 0 { if tx.execTipCap.Cmp(p.gasTip) < 0 {
// Drop the offending transaction // Drop the offending transaction
var ( var (
ids = []uint64{tx.id} dropTxs = txs[i:]
nonces = []uint64{tx.nonce} ids = make([]uint64, len(dropTxs))
nonces = make([]uint64, len(dropTxs))
) )
for j, tx := range dropTxs {
p.spent[addr] = new(uint256.Int).Sub(p.spent[addr], txs[i].costCap) p.spent[addr] = new(uint256.Int).Sub(p.spent[addr], txs[i].costCap)
p.stored -= uint64(tx.size) p.stored -= uint64(tx.size)
delete(p.lookup, tx.hash) delete(p.lookup, tx.hash)
txs[i] = nil ids[j], nonces[j] = tx.id, tx.nonce
// Drop everything afterwards, no gaps allowed
for j, tx := range txs[i+1:] {
ids = append(ids, tx.id)
nonces = append(nonces, tx.nonce)
p.spent[addr] = new(uint256.Int).Sub(p.spent[addr], tx.costCap)
p.stored -= uint64(tx.size)
delete(p.lookup, tx.hash)
txs[i+1+j] = nil
} }
// Clear out the dropped transactions from the index // Clear out the dropped transactions from the index
if i > 0 { if i > 0 {