From b98672fd567725789d1702082781393e2178ff03 Mon Sep 17 00:00:00 2001 From: zhourong Date: Wed, 28 Apr 2021 14:30:23 +0800 Subject: [PATCH] chore(mempool): remove implementation of get pool transaction --- pkg/order/mempool/mempool.go | 8 ++++---- pkg/order/mempool/mempool_impl.go | 32 ++++++++++++++++--------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/pkg/order/mempool/mempool.go b/pkg/order/mempool/mempool.go index f39c1dc..c127419 100644 --- a/pkg/order/mempool/mempool.go +++ b/pkg/order/mempool/mempool.go @@ -29,10 +29,6 @@ type MemPool interface { GetTimeoutTransactions(rebroadcastDuration time.Duration) [][]pb.Transaction - GetPendingTransactions(max int) []pb.Transaction - - GetTransaction(hash *types.Hash) pb.Transaction - SubscribeTxEvent(chan<- events.NewTxsEvent) event.Subscription External @@ -44,6 +40,10 @@ type External interface { // GetPendingNonceByAccount will return the latest pending nonce of a given account GetPendingNonceByAccount(account string) uint64 + GetPendingTransactions(max int) []pb.Transaction + + GetTransaction(hash *types.Hash) pb.Transaction + // IsPoolFull check if memPool has exceeded the limited txSize. IsPoolFull() bool } diff --git a/pkg/order/mempool/mempool_impl.go b/pkg/order/mempool/mempool_impl.go index 8d3d5f8..7d63d4f 100644 --- a/pkg/order/mempool/mempool_impl.go +++ b/pkg/order/mempool/mempool_impl.go @@ -327,22 +327,24 @@ func (mpi *mempoolImpl) GetPendingTransactions(max int) []pb.Transaction { } func (mpi *mempoolImpl) GetTransaction(hash *types.Hash) pb.Transaction { - key, ok := mpi.txStore.txHashMap[hash.String()] - if !ok { - return nil - } + // TODO: make it go routine safe + //key, ok := mpi.txStore.txHashMap[hash.String()] + //if !ok { + // return nil + //} + // + //txMap, ok := mpi.txStore.allTxs[key.account] + //if !ok { + // return nil + //} + // + //item, ok := txMap.items[key.nonce] + //if !ok { + // return nil + //} - txMap, ok := mpi.txStore.allTxs[key.account] - if !ok { - return nil - } - - item, ok := txMap.items[key.nonce] - if !ok { - return nil - } - - return item.tx + //return item.tx + return nil } func (mpi *mempoolImpl) shardTxList(timeoutItems []*orderedTimeoutKey, batchLen uint64) [][]pb.Transaction {