Subscriptions: Add List.Public, List.Enabled and List.Private (#1629)

This commit is contained in:
Gareth Kirwan
2024-10-10 04:48:16 +01:00
committed by GitHub
parent 910cdaacd4
commit c2dfb37efd
4 changed files with 66 additions and 12 deletions

View File

@@ -113,3 +113,36 @@ func (l List) assetPairs(e iExchange) (assetPairs, error) {
}
return ap, nil
}
// Enabled returns a new list of only enabled subscriptions
func (l List) Enabled() List {
n := make(List, 0, len(l))
for _, s := range l {
if s.Enabled {
n = append(n, s)
}
}
return slices.Clip(n)
}
// Private returns only subscriptions which require authentication
func (l List) Private() List {
n := List{}
for _, s := range l {
if s.Authenticated {
n = append(n, s)
}
}
return n
}
// Public returns only subscriptions which do not require authentication
func (l List) Public() List {
n := List{}
for _, s := range l {
if !s.Authenticated {
n = append(n, s)
}
}
return n
}