Skip to content

Commit

Permalink
core/txpool/legacypool: minor nitpicks
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Oct 8, 2024
1 parent 496826f commit 3d969a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
5 changes: 5 additions & 0 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ func New(config Config, chain BlockChain) *LegacyPool {
// Sanitize the input to ensure no vulnerable gas prices are set
config = (&config).sanitize()

// Disable locals-handling in this pool. This is a precursor to fully
// deleting locals-related code
config.NoLocals = true
config.Locals = nil

// Create the transaction pool with its initial settings
pool := &LegacyPool{
config: config,
Expand Down
14 changes: 7 additions & 7 deletions core/txpool/legacypool/tx_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ type TxTracker struct {

journal *journal // Journal of local transaction to back up to disk
rejournal time.Duration // How often to rotate journal
pool txpool.SubPool // The 'main' subpool to interact with
pool *txpool.TxPool // The tx pool to interact with
signer types.Signer

shutdownCh chan struct{}
mu sync.Mutex
wg sync.WaitGroup
}

func NewTxTracker(journalPath string, journalTime time.Duration, chainConfig *params.ChainConfig, next txpool.SubPool) *TxTracker {
func NewTxTracker(journalPath string, journalTime time.Duration, chainConfig *params.ChainConfig, next *txpool.TxPool) *TxTracker {
signer := types.LatestSigner(chainConfig)
pool := &TxTracker{
all: make(map[common.Hash]*types.Transaction),
Expand Down Expand Up @@ -95,20 +95,20 @@ func (tracker *TxTracker) recheck(journalCheck bool) (resubmits []*types.Transac
tracker.mu.Lock()
defer tracker.mu.Unlock()
var (
nStales = 0
nOk = 0
numStales = 0
numOk = 0
)
for sender, txs := range tracker.byAddr {
stales := txs.Forward(tracker.pool.Nonce(sender))
// Wipe the stales
for _, tx := range stales {
delete(tracker.all, tx.Hash())
}
nStales += len(stales)
numStales += len(stales)
// Check the non-stale
for _, tx := range txs.Flatten() {
if tracker.pool.Has(tx.Hash()) {
nOk++
numOk++
continue
}
resubmits = append(resubmits, tx)
Expand All @@ -129,7 +129,7 @@ func (tracker *TxTracker) recheck(journalCheck bool) (resubmits []*types.Transac
})
}
}
log.Debug("Tx tracker status", "need-resubmit", len(resubmits), "stale", nStales, "ok", nOk)
log.Debug("Tx tracker status", "need-resubmit", len(resubmits), "stale", numStales, "ok", numOk)
return resubmits, rejournal
}

Expand Down
22 changes: 5 additions & 17 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,17 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if config.TxPool.Journal != "" {
config.TxPool.Journal = stack.ResolvePath(config.TxPool.Journal)
}
// Init the legacypool without locals, to avoid collisions on the
// locals-journal.
legacyPool := legacypool.New(legacypool.Config{
Locals: nil,
NoLocals: true,
Journal: "",
Rejournal: 0,
PriceLimit: config.TxPool.PriceLimit,
PriceBump: config.TxPool.PriceBump,
AccountSlots: config.TxPool.AccountSlots,
GlobalSlots: config.TxPool.GlobalSlots,
AccountQueue: config.TxPool.AccountQueue,
GlobalQueue: config.TxPool.GlobalQueue,
Lifetime: config.TxPool.Lifetime,
}, eth.blockchain)
legacyPool := legacypool.New(config.TxPool, eth.blockchain)

eth.txPool, err = txpool.New(config.TxPool.PriceLimit, eth.blockchain, []txpool.SubPool{legacyPool, blobPool})

if !config.TxPool.NoLocals {
eth.localTxTracker = legacypool.NewTxTracker(config.TxPool.Journal,
config.TxPool.Rejournal,
eth.blockchain.Config(), legacyPool)
eth.blockchain.Config(), eth.txPool)
stack.RegisterLifecycle(eth.localTxTracker)
}

eth.txPool, err = txpool.New(config.TxPool.PriceLimit, eth.blockchain, []txpool.SubPool{legacyPool, blobPool})
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 3d969a1

Please sign in to comment.