diff --git a/exchanges/bitfinex/bitfinex_test.go b/exchanges/bitfinex/bitfinex_test.go index ccd7215e9f6..40f3a0cb0a1 100644 --- a/exchanges/bitfinex/bitfinex_test.go +++ b/exchanges/bitfinex/bitfinex_test.go @@ -1871,10 +1871,4 @@ func TestChanForSub(t *testing.T) { s, err = b.chanForSub(wsBook, asset.Spot, p) assert.Nil(t, err, "No error returned when sub found") assert.EqualValues(t, want, *s, "Correct Sub found") - - dup := stream.ChannelSubscription{Asset: asset.Spot, Currency: p, Channel: wsBook, Params: map[string]interface{}{"muffins": "yummy"}} - b.Websocket.AddSuccessfulSubscriptions(dup) - s, err = b.chanForSub(wsBook, asset.Spot, p) - assert.ErrorIs(t, err, errTooManyMatchingSubs, "Correct error returns when too many subs found") - assert.Nil(t, s, "No stream returned when too many subs found") } diff --git a/exchanges/bitfinex/bitfinex_types.go b/exchanges/bitfinex/bitfinex_types.go index e55b90ff669..6b2856d2a8d 100644 --- a/exchanges/bitfinex/bitfinex_types.go +++ b/exchanges/bitfinex/bitfinex_types.go @@ -11,10 +11,9 @@ import ( ) var ( - errSetCannotBeEmpty = errors.New("set cannot be empty") - errSubNotFound = errors.New("could not find matching subscription") - errTooManyMatchingSubs = errors.New("too many matching subscriptions") - errTypeAssert = errors.New("type assertion failed") + errSetCannotBeEmpty = errors.New("set cannot be empty") + errSubNotFound = errors.New("could not find matching subscription") + errTypeAssert = errors.New("type assertion failed") ) // AccountV2Data stores account v2 data diff --git a/exchanges/bitfinex/bitfinex_websocket.go b/exchanges/bitfinex/bitfinex_websocket.go index 796a124fd46..aea8e68cbab 100644 --- a/exchanges/bitfinex/bitfinex_websocket.go +++ b/exchanges/bitfinex/bitfinex_websocket.go @@ -1553,7 +1553,6 @@ func (b *Bitfinex) resubOrderbook(p currency.Pair, assetType asset.Item) error { // chanForSub returns an existing channel subscription for a given channel/asset/pair func (b *Bitfinex) chanForSub(cName string, assetType asset.Item, pair currency.Pair) (*stream.ChannelSubscription, error) { - var c *stream.ChannelSubscription want := &stream.ChannelSubscription{ Channel: cName, Currency: pair, @@ -1562,17 +1561,10 @@ func (b *Bitfinex) chanForSub(cName string, assetType asset.Item, pair currency. subs := b.Websocket.GetSubscriptions() for i := range subs { if subs[i].Equal(want) { - if c != nil { - return nil, errTooManyMatchingSubs - } - c = &subs[i] + return &subs[i], nil } } - if c == nil { - return nil, errSubNotFound - } - - return c, nil + return nil, errSubNotFound } // GenerateDefaultSubscriptions Adds default subscriptions to websocket to be handled by ManageSubscriptions()