Skip to content

Commit

Permalink
Merge pull request #487 from binance-chain/errorlog
Browse files Browse the repository at this point in the history
fix error log in order handler
  • Loading branch information
rickyyangz authored Mar 9, 2019
2 parents d8bcc1d + c6469a9 commit efc8811
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions plugins/dex/order/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ func validateOrder(ctx sdk.Context, pairMapper store.TradingPairMapper, acc sdk.
}

if msg.Quantity <= 0 || msg.Quantity%pair.LotSize.ToInt64() != 0 {
return errors.New(fmt.Sprintf("quantity(%v) is not rounded to lotSize(%v)", msg.Quantity, pair.LotSize))
return errors.New(fmt.Sprintf("quantity(%v) is not rounded to lotSize(%v)", msg.Quantity, pair.LotSize.ToInt64()))
}

if msg.Price <= 0 || msg.Price%pair.TickSize.ToInt64() != 0 {
return errors.New(fmt.Sprintf("price(%v) is not rounded to tickSize(%v)", msg.Price, pair.TickSize))
return errors.New(fmt.Sprintf("price(%v) is not rounded to tickSize(%v)", msg.Price, pair.TickSize.ToInt64()))
}

if utils.IsExceedMaxNotional(msg.Price, msg.Quantity) {
Expand Down Expand Up @@ -135,10 +135,7 @@ func handleNewOrder(
return sdk.NewError(types.DefaultCodespace, types.CodeFailInsertOrder, err.Error()).Result()
}
} else {
return sdk.NewError(
types.DefaultCodespace,
types.CodeFailInsertOrder,
"cannot get txHash from ctx").Result()
panic("cannot get txHash from ctx")
}
}

Expand Down Expand Up @@ -194,10 +191,7 @@ func handleCancelOrder(
// this is done in memory! we must not run this block in checktx or simulate!
if ctx.IsDeliverTx() {
if txHash, ok := ctx.Value(baseapp.TxHashKey).(string); !ok {
return sdk.NewError(
types.DefaultCodespace,
types.CodeFailCancelOrder,
"cannot get txHash from ctx").Result()
panic("cannot get txHash from ctx")
} else {
// add fee to pool, even it's free
fees.Pool.AddFee(txHash, fee)
Expand Down

0 comments on commit efc8811

Please sign in to comment.