本文整理汇总了Golang中github.com/skycoin/skycoin-exchange/src/server/engine.Exchange.GetOrders方法的典型用法代码示例。如果您正苦于以下问题:Golang Exchange.GetOrders方法的具体用法?Golang Exchange.GetOrders怎么用?Golang Exchange.GetOrders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skycoin/skycoin-exchange/src/server/engine.Exchange
的用法示例。
在下文中一共展示了Exchange.GetOrders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetOrders
// GetOrders get order list.
func GetOrders(egn engine.Exchange) sknet.HandlerFunc {
return func(c *sknet.Context) error {
rlt := &pp.EmptyRes{}
for {
req := pp.GetOrderReq{}
if err := c.BindJSON(&req); err != nil {
rlt = pp.MakeErrResWithCode(pp.ErrCode_WrongRequest)
break
}
op, err := order.TypeFromStr(req.GetType())
if err != nil {
rlt = pp.MakeErrResWithCode(pp.ErrCode_WrongRequest)
logger.Error(err.Error())
break
}
ords, err := egn.GetOrders(req.GetCoinPair(), op, req.GetStart(), req.GetEnd())
if err != nil {
rlt = pp.MakeErrResWithCode(pp.ErrCode_WrongRequest)
logger.Error(err.Error())
break
}
res := pp.GetOrderRes{
CoinPair: req.CoinPair,
Type: req.Type,
Orders: make([]*pp.Order, len(ords)),
}
for i := range ords {
res.Orders[i] = &pp.Order{
Id: &ords[i].ID,
Type: req.Type,
Price: &ords[i].Price,
Amount: &ords[i].Amount,
RestAmt: &ords[i].RestAmt,
CreatedAt: &ords[i].CreatedAt,
}
}
res.Result = pp.MakeResultWithCode(pp.ErrCode_Success)
return c.SendJSON(&res)
}
return c.Error(rlt)
}
}