From a1b0c2188e610b4956ff21fdee47570ae0ec9249 Mon Sep 17 00:00:00 2001 From: Solovyov1796 Date: Sat, 8 Mar 2025 03:21:51 +0800 Subject: [PATCH] maintain counter before clean cache --- app/priority_nonce.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/priority_nonce.go b/app/priority_nonce.go index a7c604de..5119629a 100644 --- a/app/priority_nonce.go +++ b/app/priority_nonce.go @@ -450,6 +450,14 @@ func (mp *PriorityNonceMempool) Remove(tx sdk.Tx) error { nonce = sig.Sequence } + if _, exists := mp.counterBySender[sender]; exists { + if mp.counterBySender[sender] > 1 { + mp.counterBySender[sender] -= 1 + } else { + delete(mp.counterBySender, sender) + } + } + scoreKey := txMeta{nonce: nonce, sender: sender} score, ok := mp.scores[scoreKey] if !ok { @@ -467,14 +475,6 @@ func (mp *PriorityNonceMempool) Remove(tx sdk.Tx) error { delete(mp.scores, scoreKey) mp.priorityCounts[score.priority]-- - if _, exists := mp.counterBySender[sender]; exists { - if mp.counterBySender[sender] > 1 { - mp.counterBySender[sender] -= 1 - } else { - delete(mp.counterBySender, sender) - } - } - return nil }