From e998c102cae987b3f9fa42b08ae64139c8c32c19 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 19 Aug 2020 17:57:30 +0300 Subject: [PATCH] mempool: rename NewMemPool into New "mempool" is a package name already. --- pkg/core/blockchain.go | 2 +- pkg/core/mempool/mem_pool.go | 4 ++-- pkg/core/mempool/mem_pool_test.go | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index c69116048..bac3ea1ad 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -168,7 +168,7 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L headersOpDone: make(chan struct{}), stopCh: make(chan struct{}), runToExitCh: make(chan struct{}), - memPool: mempool.NewMemPool(cfg.MemPoolSize), + memPool: mempool.New(cfg.MemPoolSize), keyCache: make(map[util.Uint160]map[string]*keys.PublicKey), sbCommittee: committee, log: log, diff --git a/pkg/core/mempool/mem_pool.go b/pkg/core/mempool/mem_pool.go index 4a862d7da..00fcb464c 100644 --- a/pkg/core/mempool/mem_pool.go +++ b/pkg/core/mempool/mem_pool.go @@ -247,8 +247,8 @@ func (mp *Pool) checkPolicy(tx *transaction.Transaction, policyChanged bool) boo return false } -// NewMemPool returns a new Pool struct. -func NewMemPool(capacity int) Pool { +// New returns a new Pool struct. +func New(capacity int) Pool { return Pool{ verifiedMap: make(map[util.Uint256]*item), verifiedTxes: make([]*item, 0, capacity), diff --git a/pkg/core/mempool/mem_pool_test.go b/pkg/core/mempool/mem_pool_test.go index ad404dcd7..a7420b255 100644 --- a/pkg/core/mempool/mem_pool_test.go +++ b/pkg/core/mempool/mem_pool_test.go @@ -28,7 +28,7 @@ func (fs *FeerStub) GetUtilityTokenBalance(uint160 util.Uint160) *big.Int { } func testMemPoolAddRemoveWithFeer(t *testing.T, fs Feer) { - mp := NewMemPool(10) + mp := New(10) tx := transaction.New(netmode.UnitTestNet, []byte{byte(opcode.PUSH1)}, 0) tx.Nonce = 0 tx.Signers = []transaction.Signer{{Account: util.Uint160{1, 2, 3}}} @@ -56,7 +56,7 @@ func TestMemPoolAddRemove(t *testing.T) { func TestOverCapacity(t *testing.T) { var fs = &FeerStub{} const mempoolSize = 10 - mp := NewMemPool(mempoolSize) + mp := New(mempoolSize) for i := 0; i < mempoolSize; i++ { tx := transaction.New(netmode.UnitTestNet, []byte{byte(opcode.PUSH1)}, 0) @@ -129,7 +129,7 @@ func TestOverCapacity(t *testing.T) { func TestGetVerified(t *testing.T) { var fs = &FeerStub{} const mempoolSize = 10 - mp := NewMemPool(mempoolSize) + mp := New(mempoolSize) txes := make([]*transaction.Transaction, 0, mempoolSize) for i := 0; i < mempoolSize; i++ { @@ -153,7 +153,7 @@ func TestGetVerified(t *testing.T) { func TestRemoveStale(t *testing.T) { var fs = &FeerStub{} const mempoolSize = 10 - mp := NewMemPool(mempoolSize) + mp := New(mempoolSize) txes1 := make([]*transaction.Transaction, 0, mempoolSize/2) txes2 := make([]*transaction.Transaction, 0, mempoolSize/2) @@ -186,7 +186,7 @@ func TestRemoveStale(t *testing.T) { } func TestMemPoolFees(t *testing.T) { - mp := NewMemPool(10) + mp := New(10) sender0 := util.Uint160{1, 2, 3} tx0 := transaction.New(netmode.UnitTestNet, []byte{byte(opcode.PUSH1)}, 0) tx0.NetworkFee = balance.Int64() + 1