Skip to content

Commit

Permalink
handle channel closures in writer
Browse files Browse the repository at this point in the history
  • Loading branch information
fbac committed Jan 16, 2025
1 parent 7f8e846 commit cf48f8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/blockchain/rpcLogStreamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (r *RpcLogStreamer) watchContract(watcher contractConfig) {
logger := r.logger.With(zap.String("contractAddress", watcher.contractAddress.Hex()))
startTime := time.Now()
defer close(watcher.eventChannel)
defer close(watcher.reorgChannel)

for {
select {
case <-r.ctx.Done():
Expand Down
6 changes: 6 additions & 0 deletions pkg/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ func NewIndexer(
func (s *Indexer) Close() {
s.log.Debug("Closing")
if s.streamer != nil {
if s.streamer.messagesReorgChannel != nil {
close(s.streamer.messagesReorgChannel)
}
if s.streamer.identityUpdatesReorgChannel != nil {
close(s.streamer.identityUpdatesReorgChannel)
}
s.streamer.streamer.Stop()
}
s.cancel()
Expand Down

0 comments on commit cf48f8c

Please sign in to comment.