Skip to content

Commit

Permalink
hare3/compat: exit if hare channel got closed (#5247)
Browse files Browse the repository at this point in the history
on close empty value will be emitted, this commit checks that and exit if channel was closed
  • Loading branch information
dshulyak committed Nov 9, 2023
1 parent c43676f commit 6c63aad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion hare3/compat/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ func ReportResult(ctx context.Context, logger *zap.Logger, from <-chan hare3.Con
case <-ctx.Done():
logger.Info("hare3 results reporter exited")
return
case out := <-from:
case out, open := <-from:
if !open {
return
}
select {
case to <- hare.LayerOutput{
Ctx: ctx,
Expand Down
5 changes: 4 additions & 1 deletion hare3/compat/weakcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ func ReportWeakcoin(ctx context.Context, logger *zap.Logger, from <-chan hare3.W
case <-ctx.Done():
logger.Info("weak coin reporter exited")
return
case out := <-from:
case out, open := <-from:
if !open {
return
}
if err := to.Set(out.Layer, out.Coin); err != nil {
logger.Error("failed to update weakcoin",
zap.Uint32("lid", out.Layer.Uint32()),
Expand Down

0 comments on commit 6c63aad

Please sign in to comment.