stream/websocket: Consolidate fields by using exchange config pointer (#809)

* stream: add exchange config pointer to setup WebsocketSetup struct to reduce and consolidate setting of variables.

* config: reduce stutter

* config: reduce minor stutter

* glorious: nits addr.

* Update exchanges/stream/websocket.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* websocket: implement fix

* engine/helpers: fix test

* exchanges: fix after merge issues

* exchange_template: fix output

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
Ryan O'Hara-Reid
2021-10-20 15:45:06 +11:00
committed by GitHub
parent a70224d123
commit 099ffa1a60
53 changed files with 611 additions and 692 deletions

View File

@@ -31,9 +31,9 @@ import (
)
// GetDefaultConfig returns a default exchange config
func (b *Bitmex) GetDefaultConfig() (*config.ExchangeConfig, error) {
func (b *Bitmex) GetDefaultConfig() (*config.Exchange, error) {
b.SetDefaults()
exchCfg := new(config.ExchangeConfig)
exchCfg := new(config.Exchange)
exchCfg.Name = b.Name
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
exchCfg.BaseCurrencies = b.BaseCurrencies
@@ -142,7 +142,7 @@ func (b *Bitmex) SetDefaults() {
}
// Setup takes in the supplied exchange configuration details and sets params
func (b *Bitmex) Setup(exch *config.ExchangeConfig) error {
func (b *Bitmex) Setup(exch *config.Exchange) error {
if !exch.Enabled {
b.SetEnabled(false)
return nil
@@ -159,21 +159,15 @@ func (b *Bitmex) Setup(exch *config.ExchangeConfig) error {
}
err = b.Websocket.Setup(&stream.WebsocketSetup{
Enabled: exch.Features.Enabled.Websocket,
Verbose: exch.Verbose,
AuthenticatedWebsocketAPISupport: exch.API.AuthenticatedWebsocketSupport,
WebsocketTimeout: exch.WebsocketTrafficTimeout,
DefaultURL: bitmexWSURL,
ExchangeName: exch.Name,
RunningURL: wsEndpoint,
Connector: b.WsConnect,
Subscriber: b.Subscribe,
UnSubscriber: b.Unsubscribe,
GenerateSubscriptions: b.GenerateDefaultSubscriptions,
Features: &b.Features.Supports.WebsocketCapabilities,
OrderbookBufferLimit: exch.OrderbookConfig.WebsocketBufferLimit,
BufferEnabled: exch.OrderbookConfig.WebsocketBufferEnabled,
UpdateEntriesByID: true,
ExchangeConfig: exch,
DefaultURL: bitmexWSURL,
RunningURL: wsEndpoint,
Connector: b.WsConnect,
Subscriber: b.Subscribe,
Unsubscriber: b.Unsubscribe,
GenerateSubscriptions: b.GenerateDefaultSubscriptions,
Features: &b.Features.Supports.WebsocketCapabilities,
UpdateEntriesByID: true,
})
if err != nil {
return err