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

@@ -36,9 +36,9 @@ const wsRateLimitMillisecond = 1000
var errNotEnoughPairs = errors.New("at least one currency is required to fetch order history")
// GetDefaultConfig returns a default exchange config
func (b *Bithumb) GetDefaultConfig() (*config.ExchangeConfig, error) {
func (b *Bithumb) 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
@@ -147,7 +147,7 @@ func (b *Bithumb) SetDefaults() {
}
// Setup takes in the supplied exchange configuration details and sets params
func (b *Bithumb) Setup(exch *config.ExchangeConfig) error {
func (b *Bithumb) Setup(exch *config.Exchange) error {
if !exch.Enabled {
b.SetEnabled(false)
return nil
@@ -167,20 +167,13 @@ func (b *Bithumb) Setup(exch *config.ExchangeConfig) error {
return err
}
err = b.Websocket.Setup(&stream.WebsocketSetup{
Enabled: exch.Features.Enabled.Websocket,
Verbose: exch.Verbose,
AuthenticatedWebsocketAPISupport: exch.API.AuthenticatedWebsocketSupport,
WebsocketTimeout: exch.WebsocketTrafficTimeout,
DefaultURL: wsEndpoint,
ExchangeName: exch.Name,
RunningURL: ePoint,
Connector: b.WsConnect,
Subscriber: b.Subscribe,
GenerateSubscriptions: b.GenerateSubscriptions,
Features: &b.Features.Supports.WebsocketCapabilities,
OrderbookBufferLimit: exch.OrderbookConfig.WebsocketBufferLimit,
OrderbookPublishPeriod: exch.OrderbookConfig.PublishPeriod,
BufferEnabled: exch.OrderbookConfig.WebsocketBufferEnabled,
ExchangeConfig: exch,
DefaultURL: wsEndpoint,
RunningURL: ePoint,
Connector: b.WsConnect,
Subscriber: b.Subscribe,
GenerateSubscriptions: b.GenerateSubscriptions,
Features: &b.Features.Supports.WebsocketCapabilities,
})
if err != nil {
return err