Skip to content

Commit

Permalink
mm: Close book feeds (#2907)
Browse files Browse the repository at this point in the history
* mm: Close book feeds

Book feeds were not being closed, leading to warning logs.
  • Loading branch information
martonp committed Aug 12, 2024
1 parent a957ee4 commit 14f573b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/mm/exchange_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2297,6 +2297,7 @@ func (u *unifiedExchangeAdaptor) cancelAllOrders(ctx context.Context) {
u.tryCancelOrders(ctx, nil, true)
return
}
defer bookFeed.Close()

mktCfg, err := u.clientCore.ExchangeMarket(u.host, u.baseID, u.quoteID)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion client/mm/mm_arb_market_maker.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ func (a *arbMarketMaker) registerFeeGap() {
}

func (a *arbMarketMaker) botLoop(ctx context.Context) (*sync.WaitGroup, error) {

book, bookFeed, err := a.core.SyncBook(a.host, a.baseID, a.quoteID)
if err != nil {
return nil, fmt.Errorf("failed to sync book: %v", err)
Expand All @@ -431,6 +430,7 @@ func (a *arbMarketMaker) botLoop(ctx context.Context) (*sync.WaitGroup, error) {

err = a.cex.SubscribeMarket(ctx, a.baseID, a.quoteID)
if err != nil {
bookFeed.Close()
return nil, fmt.Errorf("failed to subscribe to cex market: %v", err)
}

Expand All @@ -440,6 +440,7 @@ func (a *arbMarketMaker) botLoop(ctx context.Context) (*sync.WaitGroup, error) {
wg.Add(1)
go func() {
defer wg.Done()
defer bookFeed.Close()
for {
select {
case ni := <-bookFeed.Next():
Expand Down
1 change: 1 addition & 0 deletions client/mm/mm_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ func (m *basicMarketMaker) botLoop(ctx context.Context) (*sync.WaitGroup, error)
wg.Add(1)
go func() {
defer wg.Done()
defer bookFeed.Close()
for {
select {
case ni := <-bookFeed.Next():
Expand Down
2 changes: 2 additions & 0 deletions client/mm/mm_simple_arb.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ func (a *simpleArbMarketMaker) botLoop(ctx context.Context) (*sync.WaitGroup, er

err = a.cex.SubscribeMarket(ctx, a.baseID, a.quoteID)
if err != nil {
bookFeed.Close()
return nil, fmt.Errorf("failed to subscribe to cex market: %v", err)
}

Expand All @@ -457,6 +458,7 @@ func (a *simpleArbMarketMaker) botLoop(ctx context.Context) (*sync.WaitGroup, er
wg.Add(1)
go func() {
defer wg.Done()
defer bookFeed.Close()
for {
select {
case ni := <-bookFeed.Next():
Expand Down

0 comments on commit 14f573b

Please sign in to comment.