mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Merge pull request #1143 from c9s/refactor/max-client
FIX: maxapi: pass context object to the requests
This commit is contained in:
commit
7da5c8361e
|
@ -96,8 +96,8 @@ func (e *Exchange) QueryTickers(ctx context.Context, symbol ...string) (map[stri
|
|||
|
||||
tickers[toGlobalSymbol(symbol[0])] = *ticker
|
||||
} else {
|
||||
|
||||
maxTickers, err := e.client.PublicService.Tickers()
|
||||
req := e.client.NewGetTickersRequest()
|
||||
maxTickers, err := req.Do(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -130,9 +130,8 @@ func (e *Exchange) QueryTickers(ctx context.Context, symbol ...string) (map[stri
|
|||
}
|
||||
|
||||
func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
|
||||
log.Info("querying market info...")
|
||||
|
||||
remoteMarkets, err := e.client.PublicService.Markets()
|
||||
req := e.client.NewGetMarketsRequest()
|
||||
remoteMarkets, err := req.Do(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ type Ticker struct {
|
|||
VolumeInBTC fixedpoint.Value `json:"vol_in_btc"`
|
||||
}
|
||||
|
||||
func (s *PublicService) Timestamp() (int64, error) {
|
||||
func (s *PublicService) Timestamp(ctx context.Context) (int64, error) {
|
||||
req := s.client.NewGetTimestampRequest()
|
||||
ts, err := req.Do(context.Background())
|
||||
ts, err := req.Do(ctx)
|
||||
if err != nil || ts == nil {
|
||||
return 0, nil
|
||||
}
|
||||
|
@ -51,14 +51,14 @@ func (s *PublicService) Timestamp() (int64, error) {
|
|||
return int64(*ts), nil
|
||||
}
|
||||
|
||||
func (s *PublicService) Markets() ([]Market, error) {
|
||||
func (s *PublicService) Markets(ctx context.Context) ([]Market, error) {
|
||||
req := s.client.NewGetMarketsRequest()
|
||||
return req.Do(context.Background())
|
||||
return req.Do(ctx)
|
||||
}
|
||||
|
||||
func (s *PublicService) Tickers() (TickerMap, error) {
|
||||
func (s *PublicService) Tickers(ctx context.Context) (TickerMap, error) {
|
||||
req := s.client.NewGetTickersRequest()
|
||||
return req.Do(context.Background())
|
||||
return req.Do(ctx)
|
||||
}
|
||||
|
||||
func (s *PublicService) Ticker(market string) (*Ticker, error) {
|
||||
|
|
|
@ -161,7 +161,7 @@ func (c *RestClient) queryAndUpdateServerTimestamp(ctx context.Context) {
|
|||
|
||||
default:
|
||||
op := func() error {
|
||||
serverTs, err := c.PublicService.Timestamp()
|
||||
serverTs, err := c.PublicService.Timestamp(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user