From 5b23671b446bde50c27683dd0c3dd545208fc7ce Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 20 Nov 2024 13:40:09 +0800 Subject: [PATCH] types: reset order book when stream disconnected --- pkg/types/orderbook.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/types/orderbook.go b/pkg/types/orderbook.go index 0134cfbd0..328ebe204 100644 --- a/pkg/types/orderbook.go +++ b/pkg/types/orderbook.go @@ -212,6 +212,10 @@ func (sb *StreamOrderBook) updateMetrics(t time.Time) { } func (sb *StreamOrderBook) BindStream(stream Stream) { + stream.OnDisconnect(func() { + sb.Reset() + }) + stream.OnBookSnapshot(func(book SliceOrderBook) { if sb.MutexOrderBook.Symbol != book.Symbol { return