• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版9b0a600bfe6996e2f8af8b9a13efc47865195b02 (tree)
时间2020-02-12 11:34:29
作者paladz <453256728@qq.c...>
Commiterpaladz

Log Message

edit for code review

更改概述

差异

--- a/application/mov/match/match.go
+++ b/application/mov/match/match.go
@@ -237,11 +237,11 @@ func calcOppositeIndex(size int, selfIdx int) int {
237237
238238 // IsMatched check does the orders can be exchange
239239 func IsMatched(orders []*common.Order) bool {
240- if len(orders) == 0 {
240+ sortedOrders := sortOrders(orders)
241+ if len(sortedOrders) == 0 {
241242 return false
242243 }
243244
244- sortedOrders := sortOrders(orders)
245245 rate := big.NewRat(sortedOrders[0].RatioDenominator, sortedOrders[0].RatioNumerator)
246246 oppositeRate := big.NewRat(1, 1)
247247 for i := 1; i < len(sortedOrders); i++ {
@@ -285,6 +285,10 @@ func validateTradePairs(tradePairs []*common.TradePair) error {
285285 }
286286
287287 func sortOrders(orders []*common.Order) []*common.Order {
288+ if len(orders) == 0 {
289+ return nil
290+ }
291+
288292 orderMap := make(map[bc.AssetID]*common.Order)
289293 firstOrder := orders[0]
290294 for i := 1; i < len(orders); i++ {
Show on old repository browser