mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-04 19:19:44 +00:00
parent
0333107327
commit
66a64dd4c9
2 changed files with 4 additions and 1 deletions
|
@ -180,7 +180,6 @@ func (mp *Pool) Add(t *transaction.Transaction, fee Feer) error {
|
|||
return ErrDup
|
||||
}
|
||||
|
||||
mp.verifiedMap[t.Hash()] = pItem
|
||||
// Insert into sorted array (from max to min, that could also be done
|
||||
// using sort.Sort(sort.Reverse()), but it incurs more overhead. Notice
|
||||
// also that we're searching for position that is strictly more
|
||||
|
@ -209,6 +208,7 @@ func (mp *Pool) Add(t *transaction.Transaction, fee Feer) error {
|
|||
copy(mp.verifiedTxes[n+1:], mp.verifiedTxes[n:])
|
||||
mp.verifiedTxes[n] = pItem
|
||||
}
|
||||
mp.verifiedMap[t.Hash()] = pItem
|
||||
|
||||
// For lots of inputs it might be easier to push them all and sort
|
||||
// afterwards, but that requires benchmarking.
|
||||
|
|
|
@ -303,6 +303,9 @@ func TestOverCapacity(t *testing.T) {
|
|||
txcnt++
|
||||
require.Error(t, mp.Add(tx, fs))
|
||||
require.Equal(t, mempoolSize, mp.Count())
|
||||
require.Equal(t, mempoolSize, len(mp.verifiedMap))
|
||||
require.Equal(t, mempoolSize, len(mp.verifiedTxes))
|
||||
require.False(t, mp.containsKey(tx.Hash()))
|
||||
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
||||
|
||||
// But claim tx should still be there.
|
||||
|
|
Loading…
Reference in a new issue