engine/syncer: Stop orderbook fallover to REST when websocket connection is active (#1361)

* sync manager: don't fall over to rest when websocket connection active

* glorious: nits and fix bug

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2023-10-27 16:30:01 +11:00
committed by GitHub
parent 75111e08f6
commit fe779b1aa8

View File

@@ -610,6 +610,12 @@ func (m *syncManager) syncOrderbook(c *currencyPairSyncAgent, e exchange.IBotExc
e.SupportsREST() &&
time.Since(s.LastUpdated) > m.config.TimeoutWebsocket &&
time.Since(c.Created) > m.config.TimeoutWebsocket {
if w, err := e.GetWebsocket(); err == nil && w.IsConnected() {
// With an active websocket connection, we can assume the orderbook
// is being updated via the websocket connection, It could be very
// illiquid. There is no need to fall over to rest.
return
}
// Downgrade to REST
s.IsUsingWebsocket = false
s.IsUsingREST = true