From 7510505f39b2270431692cde622b314dbb86b2d7 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Sat, 21 Aug 2021 15:31:53 +0700 Subject: [PATCH] save --- txpool/pool.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/txpool/pool.go b/txpool/pool.go index 64cbdfeb6..7a01d1157 100644 --- a/txpool/pool.go +++ b/txpool/pool.go @@ -161,16 +161,12 @@ func (sc *SendersCache) evict() int { } count := 0 - for i := range sc.senderInfo { - if sc.senderInfo[i].txNonce2Tx.Len() > 0 { + for addr, id := range sc.senderIDs { + if sc.senderInfo[id].txNonce2Tx.Len() > 0 { continue } - for addr, id := range sc.senderIDs { - if id == i { - delete(sc.senderIDs, addr) - } - } - delete(sc.senderInfo, i) + delete(sc.senderInfo, id) + delete(sc.senderIDs, addr) count++ } return count @@ -548,6 +544,11 @@ func (p *TxPool) OnNewBlock(coreDB kv.Tx, stateChanges map[string]senderInfo, un } } + count := senders.evict() + if count > 0 { + log.Debug("evicted senders", "amount", count) + } + return nil } func (p *TxPool) flushIsLocalHistory(tx kv.RwTx) error { @@ -1027,11 +1028,6 @@ func BroadcastLoop(ctx context.Context, db kv.RwDB, p *TxPool, senders *SendersC case <-logEvery.C: p.logStats() case <-evictSendersEvery.C: - // evict sendersInfo without txs - count := senders.evict() - if count > 0 { - log.Debug("evicted senders", "amount", count) - } if db != nil { if err := db.Update(ctx, func(tx kv.RwTx) error { return p.flushIsLocalHistory(tx)