mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-09 01:19:05 +00:00
mempool: move metrics out of removeInternal, simplify it
Metrics should be updated once per action, currently removeInternal is used by Add and Remove, the first one updates them in the end anyway and remove should do the same. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
6334192a95
commit
a11e433754
1 changed files with 33 additions and 31 deletions
|
@ -299,12 +299,18 @@ func (mp *Pool) Add(t *transaction.Transaction, fee Feer, data ...any) error {
|
|||
func (mp *Pool) Remove(hash util.Uint256) {
|
||||
mp.lock.Lock()
|
||||
mp.removeInternal(hash)
|
||||
if mp.updateMetricsCb != nil {
|
||||
mp.updateMetricsCb(len(mp.verifiedTxes))
|
||||
}
|
||||
mp.lock.Unlock()
|
||||
}
|
||||
|
||||
// removeInternal is an internal unlocked representation of Remove.
|
||||
func (mp *Pool) removeInternal(hash util.Uint256) {
|
||||
if tx, ok := mp.verifiedMap[hash]; ok {
|
||||
tx, ok := mp.verifiedMap[hash]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var num int
|
||||
delete(mp.verifiedMap, hash)
|
||||
for num = range mp.verifiedTxes {
|
||||
|
@ -335,10 +341,6 @@ func (mp *Pool) removeInternal(hash util.Uint256) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if mp.updateMetricsCb != nil {
|
||||
mp.updateMetricsCb(len(mp.verifiedTxes))
|
||||
}
|
||||
}
|
||||
|
||||
// RemoveStale filters verified transactions through the given function keeping
|
||||
// only the transactions for which it returns true result. It's used to quickly
|
||||
|
|
Loading…
Reference in a new issue