From 53ba5182ce5726b7308e5b887f89b4af34e61ea2 Mon Sep 17 00:00:00 2001 From: qkrehdus Date: Tue, 6 Jan 2026 17:53:16 +0900 Subject: [PATCH] refactor: improve readability of patch code --- core/txpool/legacypool/legacypool.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 51d8b66530..69184eefbb 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -568,18 +568,14 @@ func (pool *LegacyPool) validateTx(tx *types.Transaction) error { FirstNonceGap: nil, // Pool allows arbitrary arrival order, don't invalidate nonce gaps UsedAndLeftSlots: nil, // Pool has own mechanism to limit the number of transactions ExistingExpenditure: func(addr common.Address) *big.Int { - list := pool.pending[addr] - queue, ok := pool.queue.get(addr) - switch { - case list != nil && ok: - return new(big.Int).Add(list.totalcost.ToBig(), queue.totalcost.ToBig()) - case list != nil: - return list.totalcost.ToBig() - case ok: - return queue.totalcost.ToBig() - default: - return new(big.Int) + result := new(big.Int) + if list := pool.pending[addr]; list != nil { + result.Add(result, list.totalcost.ToBig()) } + if queue, ok := pool.queue.get(addr); ok { + result.Add(result, queue.totalcost.ToBig()) + } + return result }, ExistingCost: func(addr common.Address, nonce uint64) *big.Int { if list := pool.pending[addr]; list != nil {