Skip to content

Commit

Permalink
Merge pull request #5661 from onflow/leo/fix-traversal-error-handling
Browse files Browse the repository at this point in the history
Fix unsafeTraverse error handling
  • Loading branch information
zhangchiqing authored Apr 23, 2024
2 parents 976e3ff + 4860e67 commit eff9395
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions state/fork/traversal.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ func unsafeTraverse(headers storage.Headers, block *flow.Header, visitor onVisit
return block, nil
}

block, err = headers.ByBlockID(block.ParentID)
parent, err := headers.ByBlockID(block.ParentID)
if err != nil {
return nil, fmt.Errorf("failed to revtrieve block header %x: %w", block.ParentID, err)
return nil, fmt.Errorf("failed to retrieve block header (id=%x height=%d): %w", block.ParentID, block.Height-1, err)
}

block = parent
}
}

0 comments on commit eff9395

Please sign in to comment.