exchanges: improves GetDefaultConfig method (#1245)

* exchanges: Add function to get standard config

* exchanges: add tests (cherry-pick here and above)

* after pick stuff

* cleanup

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2023-09-18 11:45:02 +10:00
committed by GitHub
parent ade2d9c5d2
commit 1adbc99526
33 changed files with 430 additions and 345 deletions

View File

@@ -37,12 +37,12 @@ var (
// GetDefaultConfig returns a default exchange config
func (b *Bittrex) GetDefaultConfig(ctx context.Context) (*config.Exchange, error) {
b.SetDefaults()
exchCfg := new(config.Exchange)
exchCfg.Name = b.Name
exchCfg.HTTPTimeout = exchange.DefaultHTTPTimeout
exchCfg.BaseCurrencies = b.BaseCurrencies
exchCfg, err := b.GetStandardConfig()
if err != nil {
return nil, err
}
err := b.SetupDefaults(exchCfg)
err = b.SetupDefaults(exchCfg)
if err != nil {
return nil, err
}
@@ -171,15 +171,14 @@ func (b *Bittrex) Setup(exch *config.Exchange) error {
// Websocket details setup below
err = b.Websocket.Setup(&stream.WebsocketSetup{
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.
ConnectionMonitorDelay: exch.ConnectionMonitorDelay,
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.
OrderbookBufferConfig: buffer.Config{
SortBuffer: true,
SortBufferByUpdateIDs: true,