Skip to content

Commit

Permalink
Fix U256 bytes code
Browse files Browse the repository at this point in the history
  • Loading branch information
freehere107 committed Dec 19, 2024
1 parent 7f32e9a commit ac8d979
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions types/Uint.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ type U256 struct {
}

func (u *U256) Process() {
reverseData := u.NextBytes(32)
Reverse(reverseData)
reverseData := utiles.ReverseBytes(u.NextBytes(32))
u.Value = decimal.NewFromBigInt(utiles.U256(utiles.BytesToHex(reverseData)), 0)
}

Expand Down
8 changes: 4 additions & 4 deletions utiles/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func UniqueSlice(s []string) (list []string) {
return
}

func ReverseBytes(a []byte) []byte {
for i := len(a)/2 - 1; i >= 0; i-- {
opp := len(a) - 1 - i
a[i], a[opp] = a[opp], a[i]
func ReverseBytes(b []byte) []byte {
a := make([]byte, len(b))
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
a[i], a[j] = b[j], b[i]
}
return a
}
Expand Down

0 comments on commit ac8d979

Please sign in to comment.