mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 23:16:54 +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:
@@ -29,9 +29,9 @@ import (
|
||||
)
|
||||
|
||||
// GetDefaultConfig returns a default exchange config
|
||||
func (b *Bittrex) GetDefaultConfig() (*config.ExchangeConfig, error) {
|
||||
func (b *Bittrex) 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
|
||||
@@ -141,7 +141,7 @@ func (b *Bittrex) SetDefaults() {
|
||||
}
|
||||
|
||||
// Setup takes in the supplied exchange configuration details and sets params
|
||||
func (b *Bittrex) Setup(exch *config.ExchangeConfig) error {
|
||||
func (b *Bittrex) Setup(exch *config.Exchange) error {
|
||||
if !exch.Enabled {
|
||||
b.SetEnabled(false)
|
||||
return nil
|
||||
@@ -159,27 +159,20 @@ func (b *Bittrex) Setup(exch *config.ExchangeConfig) error {
|
||||
|
||||
// Websocket details setup below
|
||||
err = b.Websocket.Setup(&stream.WebsocketSetup{
|
||||
Enabled: exch.Features.Enabled.Websocket,
|
||||
Verbose: exch.Verbose,
|
||||
AuthenticatedWebsocketAPISupport: exch.API.AuthenticatedWebsocketSupport,
|
||||
WebsocketTimeout: exch.WebsocketTrafficTimeout,
|
||||
DefaultURL: bittrexAPIWSURL, // Default ws endpoint so we can roll back via CLI if needed.
|
||||
ExchangeName: exch.Name, // Sets websocket name to the exchange name.
|
||||
RunningURL: wsRunningEndpoint,
|
||||
Connector: b.WsConnect, // Connector function outlined above.
|
||||
Subscriber: b.Subscribe, // Subscriber function outlined above.
|
||||
UnSubscriber: b.Unsubscribe, // Unsubscriber function outlined above.
|
||||
GenerateSubscriptions: b.GenerateDefaultSubscriptions, // GenerateDefaultSubscriptions function outlined above.
|
||||
Features: &b.Features.Supports.WebsocketCapabilities, // Defines the capabilities of the websocket outlined in supported features struct. This allows the websocket connection to be flushed appropriately if we have a pair/asset enable/disable change. This is outlined below.
|
||||
ExchangeConfig: exch,
|
||||
DefaultURL: bittrexAPIWSURL, // Default ws endpoint so we can roll back via CLI if needed.
|
||||
RunningURL: wsRunningEndpoint,
|
||||
Connector: b.WsConnect, // Connector function outlined above.
|
||||
Subscriber: b.Subscribe, // Subscriber function outlined above.
|
||||
Unsubscriber: b.Unsubscribe, // Unsubscriber function outlined above.
|
||||
GenerateSubscriptions: b.GenerateDefaultSubscriptions, // GenerateDefaultSubscriptions function outlined above.
|
||||
Features: &b.Features.Supports.WebsocketCapabilities, // Defines the capabilities of the websocket outlined in supported features struct. This allows the websocket connection to be flushed appropriately if we have a pair/asset enable/disable change. This is outlined below.
|
||||
|
||||
// Orderbook buffer specific variables for processing orderbook updates via websocket feed.
|
||||
// Other orderbook buffer vars:
|
||||
// UpdateEntriesByID bool
|
||||
OrderbookBufferLimit: exch.OrderbookConfig.WebsocketBufferLimit,
|
||||
OrderbookPublishPeriod: exch.OrderbookConfig.PublishPeriod,
|
||||
BufferEnabled: exch.OrderbookConfig.WebsocketBufferEnabled,
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
SortBuffer: true,
|
||||
SortBufferByUpdateIDs: true,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user