This commit is contained in:
alex.sharov 2021-08-21 15:31:53 +07:00
parent ee04be5cf3
commit 7510505f39

View File

@ -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)