From fe779b1aa8abc2c73da15064123b2a9a4df9e162 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Fri, 27 Oct 2023 16:30:01 +1100 Subject: [PATCH] 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 --- engine/sync_manager.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engine/sync_manager.go b/engine/sync_manager.go index 5c4d829f..66dd63e1 100644 --- a/engine/sync_manager.go +++ b/engine/sync_manager.go @@ -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