Skip to content

Commit

Permalink
fix: fix possible cause for memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Sep 1, 2024
1 parent c058865 commit 37bd153
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions node/pkg/chain/websocketchainreader/websocketreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,6 @@ func (c *ChainReader) handleSubscription(ctx context.Context, config *SubscribeC
Addresses: []common.Address{common.HexToAddress(config.Address)},
}

headerSubChan := make(chan *types.Header, 1)
defer close(headerSubChan)
// Subscribe to new head just to keep connection alive (ignoring the results)
subNewHead, err := c.client(config.ChainType).SubscribeNewHead(ctx, headerSubChan)
if err != nil {
log.Warn().Err(err).Msg("Failed to subscribe to new head")
} else {
defer subNewHead.Unsubscribe()
}

go func() {
for {
select {
case <-ctx.Done():
return
case <-headerSubChan:
}
}
}()

logs := make(chan types.Log)
sub, err := c.client(config.ChainType).SubscribeFilterLogs(ctx, query, logs)
if err != nil {
Expand Down

0 comments on commit 37bd153

Please sign in to comment.