OSDN Git Service

opt code fix_match
authorshenao78 <shenao.78@163.com>
Tue, 5 Nov 2019 06:19:01 +0000 (14:19 +0800)
committershenao78 <shenao.78@163.com>
Tue, 5 Nov 2019 06:19:01 +0000 (14:19 +0800)
application/mov/match/match.go

index 12a14a2..3dc4f6f 100644 (file)
@@ -42,20 +42,11 @@ func (e *Engine) HasMatchedTx(tradePairs ...*common.TradePair) bool {
 // the size of trade pairs at least 2, and the sequence of trade pairs can form a loop
 // for example, [assetA -> assetB, assetB -> assetC, assetC -> assetA]
 func (e *Engine) NextMatchedTx(tradePairs ...*common.TradePair) (*types.Tx, error) {
-       if err := validateTradePairs(tradePairs); err != nil {
-               return nil, err
-       }
-
-       orders := e.peekOrders(tradePairs)
-       if len(orders) == 0 {
-               return nil, errors.New("no order for the specified trade pair in the order table")
-       }
-
-       if !isMatched(orders) {
+       if !e.HasMatchedTx(tradePairs...) {
                return nil, errors.New("the specified trade pairs can not be matched")
        }
 
-       tx, err := e.buildMatchTx(orders)
+       tx, err := e.buildMatchTx(e.peekOrders(tradePairs))
        if err != nil {
                return nil, err
        }