mempool: remove Feer from Remove()

It's not used and not needed for removal.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2024-07-30 17:36:57 +03:00
parent d8e3e57f88
commit 6334192a95
3 changed files with 11 additions and 11 deletions

View file

@ -222,14 +222,14 @@ func (mp *Pool) Add(t *transaction.Transaction, fee Feer, data ...any) error {
mp.lock.Unlock()
return ErrOracleResponse
}
mp.removeInternal(h, fee)
mp.removeInternal(h)
}
mp.oracleResp[id] = t.Hash()
}
// Remove conflicting transactions.
for _, conflictingTx := range conflictsToBeRemoved {
mp.removeInternal(conflictingTx.Hash(), fee)
mp.removeInternal(conflictingTx.Hash())
}
// Insert into a sorted array (from max to min, that could also be done
// using sort.Sort(sort.Reverse()), but it incurs more overhead. Notice
@ -296,14 +296,14 @@ func (mp *Pool) Add(t *transaction.Transaction, fee Feer, data ...any) error {
// Remove removes an item from the mempool if it exists there (and does
// nothing if it doesn't).
func (mp *Pool) Remove(hash util.Uint256, feer Feer) {
func (mp *Pool) Remove(hash util.Uint256) {
mp.lock.Lock()
mp.removeInternal(hash, feer)
mp.removeInternal(hash)
mp.lock.Unlock()
}
// removeInternal is an internal unlocked representation of Remove.
func (mp *Pool) removeInternal(hash util.Uint256, feer Feer) {
func (mp *Pool) removeInternal(hash util.Uint256) {
if tx, ok := mp.verifiedMap[hash]; ok {
var num int
delete(mp.verifiedMap, hash)

View file

@ -53,7 +53,7 @@ func testMemPoolAddRemoveWithFeer(t *testing.T, fs Feer) {
tx2, ok := mp.TryGetValue(tx.Hash())
require.Equal(t, true, ok)
require.Equal(t, tx, tx2)
mp.Remove(tx.Hash(), fs)
mp.Remove(tx.Hash())
_, ok = mp.TryGetValue(tx.Hash())
require.Equal(t, false, ok)
// Make sure nothing left in the mempool after removal.
@ -204,7 +204,7 @@ func TestGetVerified(t *testing.T) {
require.Equal(t, mempoolSize, len(verTxes))
require.ElementsMatch(t, txes, verTxes)
for _, tx := range txes {
mp.Remove(tx.Hash(), fs)
mp.Remove(tx.Hash())
}
verTxes = mp.GetVerifiedTransactions()
require.Equal(t, 0, len(verTxes))
@ -379,7 +379,7 @@ func TestMempoolAddRemoveOracleResponse(t *testing.T) {
require.ErrorIs(t, err, ErrOracleResponse)
// ok if old tx is removed
mp.Remove(tx1.Hash(), fs)
mp.Remove(tx1.Hash())
require.NoError(t, mp.Add(tx2, fs))
// higher network fee
@ -526,12 +526,12 @@ func TestMempoolAddRemoveConflicts(t *testing.T) {
assert.Equal(t, []util.Uint256{tx3.Hash(), tx2.Hash()}, mp.conflicts[tx1.Hash()])
// manually remove tx11 with its single conflict
mp.Remove(tx11.Hash(), fs)
mp.Remove(tx11.Hash())
assert.Equal(t, 2, len(mp.conflicts))
assert.Equal(t, []util.Uint256{tx10.Hash()}, mp.conflicts[tx6.Hash()])
// manually remove last tx which conflicts with tx6 => mp.conflicts[tx6] should also be deleted
mp.Remove(tx10.Hash(), fs)
mp.Remove(tx10.Hash())
assert.Equal(t, 1, len(mp.conflicts))
assert.Equal(t, []util.Uint256{tx3.Hash(), tx2.Hash()}, mp.conflicts[tx1.Hash()])

View file

@ -67,7 +67,7 @@ func TestSubscriptions(t *testing.T) {
require.Equal(t, mempoolevent.Event{Type: mempoolevent.TransactionAdded, Tx: txs[2]}, event2)
// remove tx
mp.Remove(txs[1].Hash(), fs)
mp.Remove(txs[1].Hash())
require.Eventually(t, func() bool { return len(subChan1) == 1 && len(subChan2) == 1 }, time.Second, time.Millisecond*100)
event1 = <-subChan1
event2 = <-subChan2