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:
Gareth Kirwan
2024-10-23 06:34:01 +02:00
committed by GitHub
parent 4fc1bf0ad1
commit 4c7c0bc533
2 changed files with 15 additions and 12 deletions

View File

@@ -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