mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-08 15:11:07 +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:
@@ -30,9 +30,9 @@ import (
|
||||
)
|
||||
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (h *HitBTC) GetDefaultConfig() (*config.ExchangeConfig, error) {
|
||||
func (h *HitBTC) GetDefaultConfig() (*config.Exchange, error) {
|
||||
h.SetDefaults()
|
||||
exchCfg := new(config.ExchangeConfig)
|
||||
exchCfg := new(config.Exchange)
|
||||
exchCfg.Name = h.Name
|
||||
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
|
||||
exchCfg.BaseCurrencies = h.BaseCurrencies
|
||||
@@ -147,7 +147,7 @@ func (h *HitBTC) SetDefaults() {
|
||||
}
|
||||
|
||||
// Setup sets user exchange configuration settings
|
||||
func (h *HitBTC) Setup(exch *config.ExchangeConfig) error {
|
||||
func (h *HitBTC) Setup(exch *config.Exchange) error {
|
||||
if !exch.Enabled {
|
||||
h.SetEnabled(false)
|
||||
return nil
|
||||
@@ -164,23 +164,16 @@ func (h *HitBTC) Setup(exch *config.ExchangeConfig) error {
|
||||
}
|
||||
|
||||
err = h.Websocket.Setup(&stream.WebsocketSetup{
|
||||
Enabled: exch.Features.Enabled.Websocket,
|
||||
Verbose: exch.Verbose,
|
||||
AuthenticatedWebsocketAPISupport: exch.API.AuthenticatedWebsocketSupport,
|
||||
WebsocketTimeout: exch.WebsocketTrafficTimeout,
|
||||
DefaultURL: hitbtcWebsocketAddress,
|
||||
ExchangeName: exch.Name,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: h.WsConnect,
|
||||
Subscriber: h.Subscribe,
|
||||
UnSubscriber: h.Unsubscribe,
|
||||
GenerateSubscriptions: h.GenerateDefaultSubscriptions,
|
||||
Features: &h.Features.Supports.WebsocketCapabilities,
|
||||
OrderbookBufferLimit: exch.OrderbookConfig.WebsocketBufferLimit,
|
||||
OrderbookPublishPeriod: exch.OrderbookConfig.PublishPeriod,
|
||||
BufferEnabled: exch.OrderbookConfig.WebsocketBufferEnabled,
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: hitbtcWebsocketAddress,
|
||||
RunningURL: wsRunningURL,
|
||||
Connector: h.WsConnect,
|
||||
Subscriber: h.Subscribe,
|
||||
Unsubscriber: h.Unsubscribe,
|
||||
GenerateSubscriptions: h.GenerateDefaultSubscriptions,
|
||||
Features: &h.Features.Supports.WebsocketCapabilities,
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user