mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
mempool: swap checks in Add, fail fast
Checking for duplicates is easier than checking the balance, so it should be done first.
This commit is contained in:
parent
e998c102ca
commit
0d8cc437fe
1 changed files with 4 additions and 4 deletions
|
@ -136,14 +136,14 @@ func (mp *Pool) Add(t *transaction.Transaction, fee Feer) error {
|
|||
timeStamp: time.Now().UTC(),
|
||||
}
|
||||
mp.lock.Lock()
|
||||
if !mp.checkTxConflicts(t, fee) {
|
||||
mp.lock.Unlock()
|
||||
return ErrConflict
|
||||
}
|
||||
if mp.containsKey(t.Hash()) {
|
||||
mp.lock.Unlock()
|
||||
return ErrDup
|
||||
}
|
||||
if !mp.checkTxConflicts(t, fee) {
|
||||
mp.lock.Unlock()
|
||||
return ErrConflict
|
||||
}
|
||||
|
||||
mp.verifiedMap[t.Hash()] = pItem
|
||||
// Insert into sorted array (from max to min, that could also be done
|
||||
|
|
Loading…
Reference in a new issue