mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-29 23:16:51 +00:00
engine/websocket: subscribe to default channels only when actually needed (#610)
* if this is required by ws routines or sync manager * restore previous subscriptions on reconnect
This commit is contained in:
@@ -192,11 +192,6 @@ func (w *Websocket) Connect() error {
|
||||
w.trafficMonitor()
|
||||
w.setConnectingStatus(true)
|
||||
|
||||
// flush any subscriptions from last connection if needed
|
||||
w.subscriptionMutex.Lock()
|
||||
w.subscriptions = nil
|
||||
w.subscriptionMutex.Unlock()
|
||||
|
||||
err := w.connector()
|
||||
if err != nil {
|
||||
w.setConnectingStatus(false)
|
||||
@@ -211,6 +206,14 @@ func (w *Websocket) Connect() error {
|
||||
w.connectionMonitor()
|
||||
}
|
||||
|
||||
// Resubscribe after re-connection
|
||||
if len(w.subscriptions) != 0 {
|
||||
err = w.Subscriber(w.subscriptions)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%v Error subscribing %s", w.exchangeName, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user