diff --git a/pkg/util/uint256.go b/pkg/util/uint256.go index f3560b126..d7dd76aa2 100644 --- a/pkg/util/uint256.go +++ b/pkg/util/uint256.go @@ -26,7 +26,8 @@ func Uint256DecodeStringLE(s string) (u Uint256, err error) { if err != nil { return u, err } - return Uint256DecodeBytesLE(b) + slice.Reverse(b) + return Uint256DecodeBytesBE(b) } // Uint256DecodeStringBE attempts to decode the given string (in BE representation) diff --git a/pkg/util/uint256_test.go b/pkg/util/uint256_test.go index b1f5d2c3e..cbbeda216 100644 --- a/pkg/util/uint256_test.go +++ b/pkg/util/uint256_test.go @@ -95,3 +95,16 @@ func TestUint256_Serializable(t *testing.T) { var b util.Uint256 testserdes.EncodeDecodeBinary(t, &a, &b) } + +func BenchmarkUint256DecodeStringLE(b *testing.B) { + a := "f037308fa0ab18155bccfc08485468c112409ea5064595699e98c545f245f32d" + + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + _, err := util.Uint256DecodeStringLE(a) + if err != nil { + b.FailNow() + } + } +}