Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
fix: prevent panic on invalid target
Browse files Browse the repository at this point in the history
  • Loading branch information
jon4hz committed Nov 20, 2022
1 parent d37976f commit 28bbca3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/stratum/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func extractJob(data map[string]any) (*Job, error) {
return nil, errors.New("failed to decode target")
}
var a = binary.LittleEndian.Uint64(raw)
if a == 0 {
return nil, errors.New("invalid target")
}
job.Difficulty = 0xFFFFFFFFFFFFFFFF / a

return &job, nil
Expand Down

0 comments on commit 28bbca3

Please sign in to comment.