From: shenao78 Date: Tue, 5 Nov 2019 06:19:01 +0000 (+0800) Subject: opt code X-Git-Tag: v1.0.5~21^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=refs%2Fheads%2Ffix_match;p=bytom%2Fvapor.git opt code --- diff --git a/application/mov/match/match.go b/application/mov/match/match.go index 12a14a25..3dc4f6f5 100644 --- a/application/mov/match/match.go +++ b/application/mov/match/match.go @@ -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 }