Skip to content

Commit

Permalink
Fix nil reference panic when returning an error code
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Aug 28, 2024
1 parent f495b39 commit ec3f836
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions zk/datastream/client/stream_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,21 @@ func (c *StreamClient) GetL2BlockByNumber(blockNum uint64) (*types.FullL2Block,

re, err := c.initiateDownloadBookmark(bookmarkRaw)
if err != nil {
return nil, int(re.ErrorNum), err
errorCode := -1
if re != nil {
errorCode = int(re.ErrorNum)
}
return nil, errorCode, err
}

for l2Block == nil {
select {
case <-c.ctx.Done():
return l2Block, int(re.ErrorNum), nil
errorCode := -1
if re != nil {
errorCode = int(re.ErrorNum)
}
return l2Block, errorCode, nil
default:
}

Expand Down

0 comments on commit ec3f836

Please sign in to comment.