Skip to content

Commit

Permalink
Bitfinex: Improve websocket type assertion checks for order processing (
Browse files Browse the repository at this point in the history
thrasher-corp#1292)

* Bitfinex: Error if ws data id/cid is not a float64

* Bitfinex: Add annotation to WS id/cid assest errs
  • Loading branch information
gbjk authored and shazbert committed Nov 9, 2023
1 parent 48057e0 commit db8a422
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions exchanges/bitfinex/bitfinex_websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,9 @@ func (b *Bitfinex) handleWSNotification(d []interface{}, respRaw []byte) error {
}
case strings.Contains(channelName, wsOrderNewRequest):
if data[2] != nil {
if cid, ok := data[2].(float64); ok && cid > 0 {
if cid, ok := data[2].(float64); !ok {
return common.GetTypeAssertError("float64", data[2], channelName+" cid")
} else if cid > 0 {
if b.Websocket.Match.IncomingWithData(int64(cid), respRaw) {
return nil
}
Expand All @@ -926,7 +928,9 @@ func (b *Bitfinex) handleWSNotification(d []interface{}, respRaw []byte) error {
case strings.Contains(channelName, wsOrderUpdateRequest),
strings.Contains(channelName, wsOrderCancelRequest):
if data[0] != nil {
if id, ok := data[0].(float64); ok && id > 0 {
if id, ok := data[0].(float64); !ok {
return common.GetTypeAssertError("float64", data[0], channelName+" id")
} else if id > 0 {
if b.Websocket.Match.IncomingWithData(int64(id), respRaw) {
return nil
}
Expand Down

0 comments on commit db8a422

Please sign in to comment.