本文整理匯總了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)
}
}