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 {