mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 15:10:44 +00:00
Subscriptions: Relax subscription validation for non-existent pairs (#1635)
The subscription pairs do not need to be validated as enabled or available. The check was just belt-and-braces and didn't have a specific use-case in mind. Coinbase has a use-case for wanting to subscribe to BTC-USD when it's not enabled. Moreover, it shouldn't be our job to check this. You want a sub expanded with these pairs? Fine. Done. If it doesn't work, you can work out why
This commit is contained in:
@@ -104,6 +104,13 @@ func expandTemplate(e iExchange, s *Subscription, ap assetPairs, assets asset.It
|
||||
|
||||
subs := List{}
|
||||
|
||||
if len(s.Pairs) != 0 {
|
||||
// We deliberately do not check Availability of sub Pairs because users have edge cases to subscribe to non-existent pairs
|
||||
for a := range ap {
|
||||
ap[a] = s.Pairs
|
||||
}
|
||||
}
|
||||
|
||||
switch s.Asset {
|
||||
case asset.All:
|
||||
subCtx.AssetPairs = ap
|
||||
@@ -118,15 +125,6 @@ func expandTemplate(e iExchange, s *Subscription, ap assetPairs, assets asset.It
|
||||
}
|
||||
}
|
||||
|
||||
if len(s.Pairs) != 0 {
|
||||
for a, pairs := range subCtx.AssetPairs {
|
||||
if err := pairs.ContainsAll(s.Pairs, true); err != nil { //nolint:govet // Shadow, or gocritic will complain sloppyReassign
|
||||
return nil, err
|
||||
}
|
||||
subCtx.AssetPairs[a] = s.Pairs
|
||||
}
|
||||
}
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
if err := t.Execute(buf, subCtx); err != nil { //nolint:govet // Shadow, or gocritic will complain sloppyReassign
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user