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

Commit

Permalink
Better fix for the conversion issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Feb 14, 2022
1 parent f975dfe commit 0ef452b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func GetChildNumsFromHex(hexHash string) ([]uint32, error) {
size := 8
splitLength := int(math.Ceil(float64(strLen) / float64(size)))
childNums := make([]uint32, 0)
maxInt32 := int64(1<<(32-1) - 1)
maxInt32 := uint32(1<<(32-1) - 1)
for i := 0; i < splitLength; i++ {
start := i * size
stop := start + size
Expand All @@ -58,13 +58,11 @@ func GetChildNumsFromHex(hexHash string) ([]uint32, error) {
if err != nil {
return nil, err
}
if num > maxInt32 {
num = num - maxInt32
if num > maxInt32 {
num = maxInt32
}
num32 := uint32(num)
if num32 > maxInt32 {
num32 = num32 - maxInt32
}
childNums = append(childNums, uint32(num))
childNums = append(childNums, num32)
}

return childNums, nil
Expand Down

0 comments on commit 0ef452b

Please sign in to comment.