diff --git a/pkg/order/mempool/mempool_impl.go b/pkg/order/mempool/mempool_impl.go index 4290d48..45a471f 100644 --- a/pkg/order/mempool/mempool_impl.go +++ b/pkg/order/mempool/mempool_impl.go @@ -155,11 +155,7 @@ func (mpi *mempoolImpl) processTransactions(txs []*pb.Transaction) error { validTxs := make(map[string][]*pb.Transaction) for _, tx := range txs { // check the sequence number of tx - txAccount, err := getAccount(tx) - if err != nil { - mpi.logger.Warningf("get tx account failed, err: %s", err.Error()) - continue - } + txAccount := tx.Account() currentSeqNo := mpi.txStore.nonceCache.getPendingNonce(txAccount) if tx.Nonce < currentSeqNo { mpi.logger.Warningf("Account %s, current sequence number is %d, required %d", txAccount, tx.Nonce, currentSeqNo+1) diff --git a/pkg/order/mempool/util_test.go b/pkg/order/mempool/util_test.go index 6f1d938..8c0c8ea 100644 --- a/pkg/order/mempool/util_test.go +++ b/pkg/order/mempool/util_test.go @@ -1,32 +1,11 @@ package mempool import ( - "fmt" "testing" - "github.com/meshplus/bitxhub-model/pb" - "github.com/stretchr/testify/assert" ) -func TestGetAccount(t *testing.T) { - ast := assert.New(t) - privKey := genPrivKey() - address, _ := privKey.PublicKey().Address() - tx := constructIBTPTx(uint64(1), &privKey) - addr, err := getAccount(tx) - ast.Nil(err) - expectedAddr := fmt.Sprintf("%s-%s-%d", address, address, pb.IBTP_INTERCHAIN) - ast.Equal(expectedAddr, addr) - tx = &pb.Transaction{ - From: InterchainContractAddr, - To: InterchainContractAddr, - } - addr, err = getAccount(tx) - ast.Nil(err) - ast.Equal(addr,InterchainContractAddr.String()) -} - func TestPoolIsFull(t *testing.T) { ast := assert.New(t) mpi, _ := mockMempoolImpl() diff --git a/pkg/order/mempool/utils.go b/pkg/order/mempool/utils.go index 820ffeb..4422e28 100644 --- a/pkg/order/mempool/utils.go +++ b/pkg/order/mempool/utils.go @@ -1,7 +1,6 @@ package mempool import ( - "fmt" "strconv" "sync/atomic" "time" @@ -103,11 +102,3 @@ func newTimer(d time.Duration) *timerManager { timeoutEventC: make(chan bool), } } - -func getAccount(tx *pb.Transaction) (string, error) { - if tx.IBTP != nil { - account := fmt.Sprintf("%s-%s-%d", tx.IBTP.From, tx.IBTP.To, tx.IBTP.Category()) - return account, nil - } - return tx.From.String(), nil -}