From 5c5878968b2f46e6df9f802ca5fecb4b1a088ff0 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 23 Aug 2019 17:02:42 +0300 Subject: [PATCH] hask: import package from _pkg.dev, make it compile --- {_pkg.dev => pkg}/crypto/hash/hash.go | 2 +- {_pkg.dev => pkg}/crypto/hash/hash_test.go | 2 +- pkg/util/uint256.go | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) rename {_pkg.dev => pkg}/crypto/hash/hash.go (97%) rename {_pkg.dev => pkg}/crypto/hash/hash_test.go (91%) diff --git a/_pkg.dev/crypto/hash/hash.go b/pkg/crypto/hash/hash.go similarity index 97% rename from _pkg.dev/crypto/hash/hash.go rename to pkg/crypto/hash/hash.go index be7ab29b9..3b9197484 100755 --- a/_pkg.dev/crypto/hash/hash.go +++ b/pkg/crypto/hash/hash.go @@ -4,7 +4,7 @@ import ( "crypto/sha256" "io" - "github.com/CityOfZion/neo-go/pkg/wire/util" + "github.com/CityOfZion/neo-go/pkg/util" "golang.org/x/crypto/ripemd160" ) diff --git a/_pkg.dev/crypto/hash/hash_test.go b/pkg/crypto/hash/hash_test.go similarity index 91% rename from _pkg.dev/crypto/hash/hash_test.go rename to pkg/crypto/hash/hash_test.go index aa23718f6..b0ca0633f 100755 --- a/_pkg.dev/crypto/hash/hash_test.go +++ b/pkg/crypto/hash/hash_test.go @@ -15,7 +15,7 @@ func TestSha256(t *testing.T) { t.Fatal(err) } expected := "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" - actual := hex.EncodeToString(data.Bytes()) // MARK: In the DecodeBytes function, there is a bytes reverse, not sure why? + actual := hex.EncodeToString(data.Bytes()) assert.Equal(t, expected, actual) } diff --git a/pkg/util/uint256.go b/pkg/util/uint256.go index 07eb73001..fbf9a41a1 100644 --- a/pkg/util/uint256.go +++ b/pkg/util/uint256.go @@ -25,9 +25,8 @@ func Uint256DecodeReverseString(s string) (u Uint256, err error) { return Uint256DecodeReverseBytes(b) } -// Uint256DecodeReverseBytes attempts to decode the given string (in LE representation) into an Uint256. -func Uint256DecodeReverseBytes(b []byte) (u Uint256, err error) { - b = ArrayReverse(b) +// Uint256DecodeBytes attempts to decode the given string (in BE representation) into an Uint256. +func Uint256DecodeBytes(b []byte) (u Uint256, err error) { if len(b) != uint256Size { return u, fmt.Errorf("expected []byte of size %d got %d", uint256Size, len(b)) } @@ -35,6 +34,12 @@ func Uint256DecodeReverseBytes(b []byte) (u Uint256, err error) { return u, nil } +// Uint256DecodeReverseBytes attempts to decode the given string (in LE representation) into an Uint256. +func Uint256DecodeReverseBytes(b []byte) (u Uint256, err error) { + b = ArrayReverse(b) + return Uint256DecodeBytes(b) +} + // Bytes returns a byte slice representation of u. func (u Uint256) Bytes() []byte { return u[:]