mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-29 23:16:51 +00:00
common: update Errors type (#1129)
* common: adjust common error slice to allow multi errors.Is matching and conform to interface better * zb: forgot to save? * linties: fixies * linties: word change as well. * nitters: glorious * buts * nitters: fix glorious bug * Update common/common.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * nitters: shifty --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
@@ -1544,7 +1544,6 @@ func (b *Bitfinex) GenerateDefaultSubscriptions() ([]stream.ChannelSubscription,
|
||||
|
||||
// Subscribe sends a websocket message to receive data from the channel
|
||||
func (b *Bitfinex) Subscribe(channelsToSubscribe []stream.ChannelSubscription) error {
|
||||
var errs common.Errors
|
||||
checksum := make(map[string]interface{})
|
||||
checksum["event"] = "conf"
|
||||
checksum["flags"] = bitfinexChecksumFlag + bitfinexWsSequenceFlag
|
||||
@@ -1553,6 +1552,7 @@ func (b *Bitfinex) Subscribe(channelsToSubscribe []stream.ChannelSubscription) e
|
||||
return err
|
||||
}
|
||||
|
||||
var errs error
|
||||
for i := range channelsToSubscribe {
|
||||
req := make(map[string]interface{})
|
||||
req["event"] = "subscribe"
|
||||
@@ -1564,20 +1564,17 @@ func (b *Bitfinex) Subscribe(channelsToSubscribe []stream.ChannelSubscription) e
|
||||
|
||||
err := b.Websocket.Conn.SendJSONMessage(req)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
errs = common.AppendError(errs, err)
|
||||
continue
|
||||
}
|
||||
b.Websocket.AddSuccessfulSubscriptions(channelsToSubscribe[i])
|
||||
}
|
||||
if errs != nil {
|
||||
return errs
|
||||
}
|
||||
return nil
|
||||
return errs
|
||||
}
|
||||
|
||||
// Unsubscribe sends a websocket message to stop receiving data from the channel
|
||||
func (b *Bitfinex) Unsubscribe(channelsToUnsubscribe []stream.ChannelSubscription) error {
|
||||
var errs common.Errors
|
||||
var errs error
|
||||
for i := range channelsToUnsubscribe {
|
||||
req := make(map[string]interface{})
|
||||
req["event"] = "unsubscribe"
|
||||
@@ -1589,15 +1586,12 @@ func (b *Bitfinex) Unsubscribe(channelsToUnsubscribe []stream.ChannelSubscriptio
|
||||
|
||||
err := b.Websocket.Conn.SendJSONMessage(req)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
errs = common.AppendError(errs, err)
|
||||
continue
|
||||
}
|
||||
b.Websocket.RemoveSuccessfulUnsubscriptions(channelsToUnsubscribe[i])
|
||||
}
|
||||
if errs != nil {
|
||||
return errs
|
||||
}
|
||||
return nil
|
||||
return errs
|
||||
}
|
||||
|
||||
// WsSendAuth sends a authenticated event payload
|
||||
|
||||
Reference in New Issue
Block a user