Skip to content

Commit

Permalink
core/txpool: don't track blobtxs, don't track invalid txs
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Jan 7, 2025
1 parent 231a2a5 commit 8639d5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 9 additions & 1 deletion core/txpool/tracker/tx_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,29 @@ func New(journalPath string, journalTime time.Duration, chainConfig *params.Chai
}

// Track adds a transaction to the tracked set.
// Note: blob-type transactions are ignored.
func (tracker *TxTracker) Track(tx *types.Transaction) {
tracker.TrackAll([]*types.Transaction{tx})
}

// TrackAll adds a list of transactions to the tracked set.
// Note: blob-type transactions are ignored.
func (tracker *TxTracker) TrackAll(txs []*types.Transaction) {
tracker.mu.Lock()
defer tracker.mu.Unlock()
for _, tx := range txs {
if tx.Type() == types.BlobTxType {
continue
}
// If we're already tracking it, it's a no-op
if _, ok := tracker.all[tx.Hash()]; ok {
continue
}
tracker.all[tx.Hash()] = tx
addr, _ := types.Sender(tracker.signer, tx)
addr, err := types.Sender(tracker.signer, tx)
if err != nil { // Ignore this tx
continue
}
if tracker.byAddr[addr] == nil {
tracker.byAddr[addr] = legacypool.NewSortedMap()
}
Expand Down
1 change: 0 additions & 1 deletion core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ func (p *TxPool) Add(txs []*types.Transaction, sync bool) []error {
// back the errors into the original sort order.
errsets := make([][]error, len(p.subpools))
for i := 0; i < len(p.subpools); i++ {
// Note: local is explicitly set to false here.
errsets[i] = p.subpools[i].Add(txsets[i], sync)
}
errs := make([]error, len(txs))
Expand Down

0 comments on commit 8639d5c

Please sign in to comment.