mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 23:33:37 +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(),
|
timeStamp: time.Now().UTC(),
|
||||||
}
|
}
|
||||||
mp.lock.Lock()
|
mp.lock.Lock()
|
||||||
if !mp.checkTxConflicts(t, fee) {
|
|
||||||
mp.lock.Unlock()
|
|
||||||
return ErrConflict
|
|
||||||
}
|
|
||||||
if mp.containsKey(t.Hash()) {
|
if mp.containsKey(t.Hash()) {
|
||||||
mp.lock.Unlock()
|
mp.lock.Unlock()
|
||||||
return ErrDup
|
return ErrDup
|
||||||
}
|
}
|
||||||
|
if !mp.checkTxConflicts(t, fee) {
|
||||||
|
mp.lock.Unlock()
|
||||||
|
return ErrConflict
|
||||||
|
}
|
||||||
|
|
||||||
mp.verifiedMap[t.Hash()] = pItem
|
mp.verifiedMap[t.Hash()] = pItem
|
||||||
// Insert into sorted array (from max to min, that could also be done
|
// Insert into sorted array (from max to min, that could also be done
|
||||||
|
|
Loading…
Reference in a new issue