mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
add method descriptors. add DropAllTxs to subpool interface. clean up the impls a bit
This commit is contained in:
parent
4fa5629f31
commit
2fa5e6255a
3 changed files with 44 additions and 35 deletions
|
|
@ -325,26 +325,6 @@ type BlobPool struct {
|
||||||
lock sync.RWMutex // Mutex protecting the pool during reorg handling
|
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
|
// New creates a new blob transaction pool to gather, sort and filter inbound
|
||||||
// blob transactions from the network.
|
// blob transactions from the network.
|
||||||
func New(config Config, chain BlockChain) *BlobPool {
|
func New(config Config, chain BlockChain) *BlobPool {
|
||||||
|
|
@ -1734,3 +1714,25 @@ func (p *BlobPool) Status(hash common.Hash) txpool.TxStatus {
|
||||||
}
|
}
|
||||||
return txpool.TxStatusUnknown
|
return txpool.TxStatusUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DropAllTxs implements txpool.SubPool, removing all tracked transactions
|
||||||
|
// from the blob pool and persistent store.
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -239,21 +239,6 @@ type txpoolResetRequest struct {
|
||||||
oldHead, newHead *types.Header
|
oldHead, newHead *types.Header
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *LegacyPool) DropAllTxs() {
|
|
||||||
p.mu.Lock()
|
|
||||||
defer p.mu.Unlock()
|
|
||||||
p.all = newLookup()
|
|
||||||
p.priced = newPricedList(p.all)
|
|
||||||
p.pending = make(map[common.Address]*list)
|
|
||||||
p.queue = make(map[common.Address]*list)
|
|
||||||
if !p.config.NoLocals && p.config.Journal != "" {
|
|
||||||
p.journal = newTxJournal(p.config.Journal)
|
|
||||||
if err := p.journal.rotate(p.local()); err != nil {
|
|
||||||
log.Warn("Failed to rotate transaction journal", "err", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// New creates a new transaction pool to gather, sort and filter inbound
|
// New creates a new transaction pool to gather, sort and filter inbound
|
||||||
// transactions from the network.
|
// transactions from the network.
|
||||||
func New(config Config, chain BlockChain) *LegacyPool {
|
func New(config Config, chain BlockChain) *LegacyPool {
|
||||||
|
|
@ -1976,3 +1961,22 @@ func (t *lookup) RemotesBelowTip(threshold *big.Int) types.Transactions {
|
||||||
func numSlots(tx *types.Transaction) int {
|
func numSlots(tx *types.Transaction) int {
|
||||||
return int((tx.Size() + txSlotSize - 1) / txSlotSize)
|
return int((tx.Size() + txSlotSize - 1) / txSlotSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DropAllTxs implements txpool.SubPool, removing all tracked txs from the pool
|
||||||
|
// and rotating the journal.
|
||||||
|
func (p *LegacyPool) DropAllTxs() {
|
||||||
|
p.mu.Lock()
|
||||||
|
defer p.mu.Unlock()
|
||||||
|
|
||||||
|
p.all = newLookup()
|
||||||
|
p.priced = newPricedList(p.all)
|
||||||
|
p.pending = make(map[common.Address]*list)
|
||||||
|
p.queue = make(map[common.Address]*list)
|
||||||
|
|
||||||
|
if !p.config.NoLocals && p.config.Journal != "" {
|
||||||
|
p.journal = newTxJournal(p.config.Journal)
|
||||||
|
if err := p.journal.rotate(p.local()); err != nil {
|
||||||
|
log.Warn("Failed to rotate transaction journal", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,4 +168,7 @@ type SubPool interface {
|
||||||
// Status returns the known status (unknown/pending/queued) of a transaction
|
// Status returns the known status (unknown/pending/queued) of a transaction
|
||||||
// identified by their hashes.
|
// identified by their hashes.
|
||||||
Status(hash common.Hash) TxStatus
|
Status(hash common.Hash) TxStatus
|
||||||
|
|
||||||
|
// DropAllTxs removes all tracked transactions from the pool
|
||||||
|
DropAllTxs()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue