From 6334192a957e2aec7a391ea412c5bf334072bd68 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 30 Jul 2024 17:36:57 +0300 Subject: [PATCH] mempool: remove Feer from Remove() It's not used and not needed for removal. Signed-off-by: Roman Khimov --- pkg/core/mempool/mem_pool.go | 10 +++++----- pkg/core/mempool/mem_pool_test.go | 10 +++++----- pkg/core/mempool/subscriptions_test.go | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/core/mempool/mem_pool.go b/pkg/core/mempool/mem_pool.go index aecd774cd..5e36fd525 100644 --- a/pkg/core/mempool/mem_pool.go +++ b/pkg/core/mempool/mem_pool.go @@ -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) diff --git a/pkg/core/mempool/mem_pool_test.go b/pkg/core/mempool/mem_pool_test.go index 430f4ea05..81c515ae9 100644 --- a/pkg/core/mempool/mem_pool_test.go +++ b/pkg/core/mempool/mem_pool_test.go @@ -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()]) diff --git a/pkg/core/mempool/subscriptions_test.go b/pkg/core/mempool/subscriptions_test.go index d476f20bc..a935cfec9 100644 --- a/pkg/core/mempool/subscriptions_test.go +++ b/pkg/core/mempool/subscriptions_test.go @@ -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