chore(mempool): remove implementation of get pool transaction

This commit is contained in:
zhourong 2021-04-28 14:30:23 +08:00
parent eec3966c76
commit b98672fd56
2 changed files with 21 additions and 19 deletions

View File

@ -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
}

View File

@ -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 {