aboutsummaryrefslogtreecommitdiffstats
path: root/core/tx_pool.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-07-05 22:16:42 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-07-05 22:16:42 +0800
commit88b4fe7d21bf03bbe01961dc49508bcf4edafb51 (patch)
treeda245a2ec8cd4102a996e3b8bb22b2d7b9ff6383 /core/tx_pool.go
parent5e38f7a664aa5401117f1e1705ec97476b19411e (diff)
downloadgo-tangerine-88b4fe7d21bf03bbe01961dc49508bcf4edafb51.tar
go-tangerine-88b4fe7d21bf03bbe01961dc49508bcf4edafb51.tar.gz
go-tangerine-88b4fe7d21bf03bbe01961dc49508bcf4edafb51.tar.bz2
go-tangerine-88b4fe7d21bf03bbe01961dc49508bcf4edafb51.tar.lz
go-tangerine-88b4fe7d21bf03bbe01961dc49508bcf4edafb51.tar.xz
go-tangerine-88b4fe7d21bf03bbe01961dc49508bcf4edafb51.tar.zst
go-tangerine-88b4fe7d21bf03bbe01961dc49508bcf4edafb51.zip
core: handle nolocals during add, exepmt locals from expiration
Diffstat (limited to 'core/tx_pool.go')
-rw-r--r--core/tx_pool.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/core/tx_pool.go b/core/tx_pool.go
index 093d3c5fd..46b09c8af 100644
--- a/core/tx_pool.go
+++ b/core/tx_pool.go
@@ -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())