From d6938a548a5d2d056ad4c7ad1069e3e14e9baf10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BA=E9=B9=8F=E9=A3=9E?= Date: Thu, 20 Dec 2018 21:03:48 +0800 Subject: [PATCH] feat(core/tx_pool.go): ignore local tx on discard process When geth starts, if local txs are too many (>10k), load and try to discard underpriced txs can be very very slowly! But the local txs are never discard on this process, so we can ignore local txs. --- AUTHORS | 1 + core/tx_pool.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 609dc48c72..741eb5482c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -172,3 +172,4 @@ yoza ΞTHΞЯSPHΞЯΞ <{viktor.tron,nagydani,zsfelfoldi}@gmail.com> Максим Чусовлянов Ralph Caraveo +hpf diff --git a/core/tx_pool.go b/core/tx_pool.go index fc35d1f243..66e1cad352 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -630,7 +630,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (bool, error) { return false, err } // If the transaction pool is full, discard underpriced transactions - if uint64(pool.all.Count()) >= pool.config.GlobalSlots+pool.config.GlobalQueue { + if !local && uint64(pool.all.Count()) >= pool.config.GlobalSlots+pool.config.GlobalQueue { // If the new transaction is underpriced, don't accept it if !local && pool.priced.Underpriced(tx, pool.locals) { log.Trace("Discarding underpriced transaction", "hash", hash, "price", tx.GasPrice())