Skip to content

Commit

Permalink
Bitfinex: Simplify string uses of chanId
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Oct 1, 2023
1 parent fbca4fc commit beb8140
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions exchanges/bitfinex/bitfinex_websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,20 +438,20 @@ func (b *Bitfinex) handleWSEvent(respRaw []byte) error {
return fmt.Errorf("%v channel subscribe listener not found", subID)
}
case wsEventUnsubscribed:
chanID, err := jsonparser.GetInt(respRaw, "chanId")
chanID, err := jsonparser.GetUnsafeString(respRaw, "chanId")
if err != nil {
return fmt.Errorf("error parsing WS unsubscribed event chanId: %w from message: %s", err, respRaw)
}
if !b.Websocket.Match.IncomingWithData("unsubscribe:"+strconv.Itoa(int(chanID)), respRaw) {
if !b.Websocket.Match.IncomingWithData("unsubscribe:"+chanID, respRaw) {
return fmt.Errorf("%v channel unsubscribe listener not found", chanID)
}
case wsEventError:
if subID, err := jsonparser.GetUnsafeString(respRaw, "subId"); err == nil {
if !b.Websocket.Match.IncomingWithData("subscribe:"+subID, respRaw) {
return fmt.Errorf("%v channel subscribe listener not found", subID)
}
} else if chanID, err := jsonparser.GetInt(respRaw, "chanId"); err == nil {
if !b.Websocket.Match.IncomingWithData("unsubscribe:"+strconv.Itoa(int(chanID)), respRaw) {
} else if chanID, err := jsonparser.GetUnsafeString(respRaw, "chanId"); err == nil {
if !b.Websocket.Match.IncomingWithData("unsubscribe:"+chanID, respRaw) {
return fmt.Errorf("%v channel unsubscribe listener not found", chanID)
}
} else {
Expand Down

0 comments on commit beb8140

Please sign in to comment.