From f162e61947fcfd79bfbfc33e39e4da38738ad3a5 Mon Sep 17 00:00:00 2001 From: andyzhang2023 Date: Tue, 9 Apr 2024 17:54:42 +0800 Subject: [PATCH] reuse the signer cache from pool --- core/txpool/legacypool/legacypool.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index b4618338e2..000568cdfc 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -1430,14 +1430,18 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) (demoteAddrs []com var collectAddr = func(txs types.Transactions) { addrs := make(map[common.Address]struct{}) for _, tx := range txs { + if !pool.Filter(tx) { + continue + } + // it is heavy to get sender from tx, so we try to get it from the pool + if oldtx := pool.all.Get(tx.Hash()); oldtx != nil { + tx = oldtx + } addr, err := types.Sender(pool.signer, tx) //it might come from other pool, by other signer if err != nil { continue } - if !pool.Filter(tx) { - continue - } addrs[addr] = struct{}{} } demoteAddrs = make([]common.Address, 0, len(addrs))