Skip to content

Commit

Permalink
Joe review and other logging fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
martonp committed Dec 7, 2024
1 parent 460d1be commit dd21473
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions client/mm/libxc/binance.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ func (bnc *binance) refreshBalances(ctx context.Context) error {
var resp bntypes.Account
err := bnc.getAPI(ctx, "/api/v3/account", nil, true, true, &resp)
if err != nil {
return fmt.Errorf("error getting balances: %w", err)
return err
}

tokenIDsI := bnc.tokenIDs.Load()
Expand Down Expand Up @@ -643,7 +643,7 @@ func (bnc *binance) getCoinInfo(ctx context.Context) error {
coins := make([]*bntypes.CoinInfo, 0)
err := bnc.getAPI(ctx, "/sapi/v1/capital/config/getall", nil, true, true, &coins)
if err != nil {
return fmt.Errorf("error getting binance coin info: %w", err)
return err
}

bnc.readCoins(coins)
Expand All @@ -654,7 +654,7 @@ func (bnc *binance) getMarkets(ctx context.Context) (map[string]*bntypes.Market,
var exchangeInfo bntypes.ExchangeInfo
err := bnc.getAPI(ctx, "/api/v3/exchangeInfo", nil, false, false, &exchangeInfo)
if err != nil {
return nil, fmt.Errorf("error getting markets from Binance: %w", err)
return nil, err
}

marketsMap := make(map[string]*bntypes.Market, len(exchangeInfo.Symbols))
Expand Down Expand Up @@ -712,11 +712,11 @@ func (bnc *binance) Connect(ctx context.Context) (*sync.WaitGroup, error) {
}

if err := bnc.setBalances(ctx); err != nil {
return nil, err
return nil, fmt.Errorf("error getting balances")
}

if err := bnc.getUserDataStream(ctx); err != nil {
return nil, err
return nil, fmt.Errorf("error getting user data stream")
}

// Refresh balances periodically. This is just for safety as they should
Expand Down Expand Up @@ -1329,9 +1329,10 @@ func (bnc *binance) request(ctx context.Context, method, endpoint string, query,
Msg string `json:"msg"`
}
if err := dexnet.Do(req, thing, dexnet.WithSizeLimit(1<<24), dexnet.WithErrorParsing(&errPayload)); err != nil {
bnc.log.Errorf("request error from endpoint %s %q with query = %q, body = %q", method, endpoint, queryString, bodyString)
bnc.log.Errorf("request error from endpoint %s %q with query = %q, body = %q, err = %v, bn code = %d, msg = %q",
method, endpoint, queryString, bodyString, err, errPayload.Code, errPayload.Msg)
if errPayload.Msg != "" {
return fmt.Errorf("Binance error: %v", errPayload.Msg)
return fmt.Errorf("Binance error: %v (%d)", errPayload.Msg, errPayload.Code)
}
return err
}
Expand Down Expand Up @@ -1513,7 +1514,7 @@ func (bnc *binance) getUserDataStream(ctx context.Context) (err error) {

cm := dex.NewConnectionMaster(conn)
if err = cm.ConnectOnce(ctx); err != nil {
return nil, fmt.Errorf("user data stream connection error: %v", err)
return nil, err
}

return cm, nil
Expand Down
2 changes: 1 addition & 1 deletion client/mm/mm.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ func (m *MarketMaker) Connect(ctx context.Context) (*sync.WaitGroup, error) {
// Try to connect so we can update our balances and set the
// connected flag, but ignore errors.
if err := m.connectCEX(ctx, c); err != nil {
m.log.Infof("Could not connect to %q: %w", cexCfg.Name, err)
m.log.Infof("Could not connect to %q: %v", cexCfg.Name, err)
}
}
}
Expand Down

0 comments on commit dd21473

Please sign in to comment.