core: handle nolocals during add, exepmt locals from expiration
This commit is contained in:
parent
5e38f7a664
commit
88b4fe7d21
@ -396,7 +396,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
||||
}
|
||||
// Drop non-local transactions under our own minimal accepted gas price
|
||||
local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network
|
||||
if (!local || pool.config.NoLocals) && pool.gasPrice.Cmp(tx.GasPrice()) > 0 {
|
||||
if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 {
|
||||
return ErrUnderpriced
|
||||
}
|
||||
// Ensure the transaction adheres to nonce ordering
|
||||
@ -482,7 +482,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if local && !pool.config.NoLocals {
|
||||
if local {
|
||||
pool.locals.add(from)
|
||||
}
|
||||
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
|
||||
// the sender as a local one in the mean time, ensuring it goes around the local
|
||||
// pricing constraints.
|
||||
func (pool *TxPool) AddLocal(tx *types.Transaction) error {
|
||||
return pool.addTx(tx, true)
|
||||
return pool.addTx(tx, !pool.config.NoLocals)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// marking the senders as a local ones in the mean time, ensuring they go around
|
||||
// the local pricing constraints.
|
||||
func (pool *TxPool) AddLocals(txs []*types.Transaction) error {
|
||||
return pool.addTxs(txs, true)
|
||||
return pool.addTxs(txs, !pool.config.NoLocals)
|
||||
}
|
||||
|
||||
// AddRemotes enqueues a batch of transactions into the pool if they are valid.
|
||||
@ -924,6 +924,11 @@ func (pool *TxPool) expirationLoop() {
|
||||
case <-evict.C:
|
||||
pool.mu.Lock()
|
||||
for addr := range pool.queue {
|
||||
// Skip local transactions from the eviction mechanism
|
||||
if pool.locals.contains(addr) {
|
||||
continue
|
||||
}
|
||||
// Any non-locals old enough should be removed
|
||||
if time.Since(pool.beats[addr]) > pool.config.Lifetime {
|
||||
for _, tx := range pool.queue[addr].Flatten() {
|
||||
pool.removeTx(tx.Hash())
|
||||
|
Loading…
Reference in New Issue
Block a user