Skip to content

Commit

Permalink
refactor: refactor error handling in block lookup process
Browse files Browse the repository at this point in the history
- Simplify error handling by changing the condition for cancellation in the block lookup process.
- Add a log message for when block scanning is canceled.
- Improve readability by restructuring the error check logic.

Signed-off-by: Sean Zheng <[email protected]>
  • Loading branch information
blackhorseya committed Oct 4, 2024
1 parent d201a0e commit 0a9830f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/domain/block/block_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ func (i *impl) ScanBlock(req *biz.ScanBlockRequest, stream biz.BlockService_Scan
// 更新主鏈區塊以繼續監控新地分片區塊
nextSeqNo := master.SeqNo + 1
master, err2 = api.WaitForBlock(nextSeqNo).LookupBlock(ctx, master.Workchain, master.Shard, nextSeqNo)
if err2 != nil && !errors.Is(err2, context.Canceled) {
if errors.Is(err2, context.Canceled) {
ctx.Info("scan block canceled")
return nil
}
if err2 != nil {
ctx.Error("failed to lookup next block", zap.Uint32("seq_no", nextSeqNo), zap.Error(err2))
return err2
}
Expand Down

0 comments on commit 0a9830f

Please sign in to comment.