mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 23:16:53 +00:00
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:
@@ -25,7 +25,7 @@ func TestMain(m *testing.M) {
|
||||
if err != nil {
|
||||
log.Fatal("ZB load config error", err)
|
||||
}
|
||||
var zbConfig *config.ExchangeConfig
|
||||
var zbConfig *config.Exchange
|
||||
zbConfig, err = cfg.GetExchangeConfig("ZB")
|
||||
if err != nil {
|
||||
log.Fatal("ZB Setup() init error", err)
|
||||
|
||||
@@ -30,9 +30,9 @@ import (
|
||||
)
|
||||
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (z *ZB) GetDefaultConfig() (*config.ExchangeConfig, error) {
|
||||
func (z *ZB) GetDefaultConfig() (*config.Exchange, error) {
|
||||
z.SetDefaults()
|
||||
exchCfg := new(config.ExchangeConfig)
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = z.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = z.BaseCurrencies
|
||||
@@ -148,7 +148,7 @@ func (z *ZB) SetDefaults() {
|
||||
}
|
||||
|
||||
// Setup sets user configuration
|
||||
func (z *ZB) Setup(exch *config.ExchangeConfig) error {
|
||||
func (z *ZB) Setup(exch *config.Exchange) error {
|
||||
if !exch.Enabled {
|
||||
z.SetEnabled(false)
|
||||
return nil
|
||||
@@ -165,20 +165,13 @@ func (z *ZB) Setup(exch *config.ExchangeConfig) error {
|
||||
}
|
||||
|
||||
err = z.Websocket.Setup(&stream.WebsocketSetup{
|
||||
Enabled: exch.Features.Enabled.Websocket,
|
||||
Verbose: exch.Verbose,
|
||||
AuthenticatedWebsocketAPISupport: exch.API.AuthenticatedWebsocketSupport,
|
||||
WebsocketTimeout: exch.WebsocketTrafficTimeout,
|
||||
DefaultURL: zbWebsocketAPI,
|
||||
ExchangeName: exch.Name,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: z.WsConnect,
|
||||
GenerateSubscriptions: z.GenerateDefaultSubscriptions,
|
||||
Subscriber: z.Subscribe,
|
||||
Features: &z.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferLimit: exch.OrderbookConfig.WebsocketBufferLimit,
|
||||
OrderbookPublishPeriod: exch.OrderbookConfig.PublishPeriod,
|
||||
BufferEnabled: exch.OrderbookConfig.WebsocketBufferEnabled,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: zbWebsocketAPI,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: z.WsConnect,
|
||||
GenerateSubscriptions: z.GenerateDefaultSubscriptions,
|
||||
Subscriber: z.Subscribe,
|
||||
Features: &z.Features.Supports.WebsocketCapabilities,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user