Skip to content

Commit 88b4fe7

Browse files
committed
core: handle nolocals during add, exepmt locals from expiration
1 parent 5e38f7a commit 88b4fe7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

core/tx_pool.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
396396
}
397397
// Drop non-local transactions under our own minimal accepted gas price
398398
local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network
399-
if (!local || pool.config.NoLocals) && pool.gasPrice.Cmp(tx.GasPrice()) > 0 {
399+
if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 {
400400
return ErrUnderpriced
401401
}
402402
// Ensure the transaction adheres to nonce ordering
@@ -482,7 +482,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (bool, error) {
482482
if err != nil {
483483
return false, err
484484
}
485-
if local && !pool.config.NoLocals {
485+
if local {
486486
pool.locals.add(from)
487487
}
488488
log.Trace("Pooled new future transaction", "hash", hash, "from", from, "to", tx.To())
@@ -556,7 +556,7 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
556556
// the sender as a local one in the mean time, ensuring it goes around the local
557557
// pricing constraints.
558558
func (pool *TxPool) AddLocal(tx *types.Transaction) error {
559-
return pool.addTx(tx, true)
559+
return pool.addTx(tx, !pool.config.NoLocals)
560560
}
561561

562562
// AddRemote enqueues a single transaction into the pool if it is valid. If the
@@ -570,7 +570,7 @@ func (pool *TxPool) AddRemote(tx *types.Transaction) error {
570570
// marking the senders as a local ones in the mean time, ensuring they go around
571571
// the local pricing constraints.
572572
func (pool *TxPool) AddLocals(txs []*types.Transaction) error {
573-
return pool.addTxs(txs, true)
573+
return pool.addTxs(txs, !pool.config.NoLocals)
574574
}
575575

576576
// AddRemotes enqueues a batch of transactions into the pool if they are valid.
@@ -924,6 +924,11 @@ func (pool *TxPool) expirationLoop() {
924924
case <-evict.C:
925925
pool.mu.Lock()
926926
for addr := range pool.queue {
927+
// Skip local transactions from the eviction mechanism
928+
if pool.locals.contains(addr) {
929+
continue
930+
}
931+
// Any non-locals old enough should be removed
927932
if time.Since(pool.beats[addr]) > pool.config.Lifetime {
928933
for _, tx := range pool.queue[addr].Flatten() {
929934
pool.removeTx(tx.Hash())

0 commit comments

Comments
 (0)