Skip to content

Commit

Permalink
Kraken: Fix Asset not known during sub processing
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Jul 23, 2024
1 parent 6e00563 commit 6fd9a3b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 2 additions & 0 deletions exchanges/kraken/kraken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ func TestWsOrderbookSub(t *testing.T) {
testexch.SetupWs(t, k)

err := k.Subscribe(subscription.List{{
Asset: asset.Spot,
Channel: subscription.OrderbookChannel,
Pairs: currency.Pairs{xbtusdPair},
Levels: 25,
Expand Down Expand Up @@ -1051,6 +1052,7 @@ func TestWsCandlesSub(t *testing.T) {
testexch.SetupWs(t, k)

err := k.Subscribe(subscription.List{{
Asset: asset.Spot,
Channel: subscription.CandlesChannel,
Pairs: currency.Pairs{xbtusdPair},
Interval: kline.OneHour,
Expand Down
9 changes: 3 additions & 6 deletions exchanges/kraken/kraken_websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,6 @@ func (k *Kraken) manageSubs(op string, subs subscription.List) error {
r.Subscription.Interval = int(time.Duration(s.Interval).Minutes())
}

if !s.Asset.IsValid() {
s.Asset = asset.Spot
}

conn := k.Websocket.Conn
if s.Authenticated {
r.Subscription.Token = authToken
Expand Down Expand Up @@ -1203,14 +1199,15 @@ func (k *Kraken) wsProcessSubStatus(resp []byte) {
return
}
key := &subscription.Subscription{
// We don't use asset because it's either Empty or Spot, but not both
Channel: channelName,
Asset: asset.Spot,
Pairs: currency.Pairs{pair},
}

if err = fqChannelNameSub(key); err != nil {
return
}
s := k.Websocket.GetSubscription(key)
s := k.Websocket.GetSubscription(&subscription.IgnoringAssetKey{key})

Check failure on line 1210 in exchanges/kraken/kraken_websocket.go

View workflow job for this annotation

GitHub Actions / lint

composites: github.com/thrasher-corp/gocryptotrader/exchanges/subscription.IgnoringAssetKey struct literal uses unkeyed fields (govet)
if s == nil {
log.Errorf(log.ExchangeSys, "%s %s Channel: %s Pairs: %s", k.Name, subscription.ErrNotFound, key.Channel, key.Pairs.Join())
return
Expand Down

0 comments on commit 6fd9a3b

Please sign in to comment.