X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=vendor%2Fgithub.com%2Ftendermint%2Fgo-wire%2Futil.go;fp=vendor%2Fgithub.com%2Ftendermint%2Fgo-wire%2Futil.go;h=751f4bfcc67b1f6ae66a347691c70df0cfb548d6;hp=4e206197a9f0888578d7b2e274eaf5356da05fee;hb=54373c1a3efe0e373ec1605840a4363e4b246c46;hpb=ee01d543fdfe1fd0a4d548965c66f7923ea7b062 diff --git a/vendor/github.com/tendermint/go-wire/util.go b/vendor/github.com/tendermint/go-wire/util.go index 4e206197..751f4bfc 100644 --- a/vendor/github.com/tendermint/go-wire/util.go +++ b/vendor/github.com/tendermint/go-wire/util.go @@ -2,10 +2,6 @@ package wire import ( "bytes" - "crypto/sha256" - "encoding/json" - - "golang.org/x/crypto/ripemd160" cmn "github.com/tendermint/tmlibs/common" ) @@ -34,58 +30,3 @@ func JSONBytes(o interface{}) []byte { } return w.Bytes() } - -// NOTE: inefficient -func JSONBytesPretty(o interface{}) []byte { - jsonBytes := JSONBytes(o) - var object interface{} - err := json.Unmarshal(jsonBytes, &object) - if err != nil { - cmn.PanicSanity(err) - } - jsonBytes, err = json.MarshalIndent(object, "", "\t") - if err != nil { - cmn.PanicSanity(err) - } - return jsonBytes -} - -// ptr: a pointer to the object to be filled -func ReadJSONBytes(d []byte, ptr interface{}) (err error) { - ReadJSONPtr(ptr, d, &err) - return -} - -// NOTE: does not care about the type, only the binary representation. -func BinaryEqual(a, b interface{}) bool { - aBytes := BinaryBytes(a) - bBytes := BinaryBytes(b) - return bytes.Equal(aBytes, bBytes) -} - -// NOTE: does not care about the type, only the binary representation. -func BinaryCompare(a, b interface{}) int { - aBytes := BinaryBytes(a) - bBytes := BinaryBytes(b) - return bytes.Compare(aBytes, bBytes) -} - -// NOTE: only use this if you need 32 bytes. -func BinarySha256(o interface{}) []byte { - hasher, n, err := sha256.New(), new(int), new(error) - WriteBinary(o, hasher, n, err) - if *err != nil { - cmn.PanicSanity(*err) - } - return hasher.Sum(nil) -} - -// NOTE: The default hash function is Ripemd160. -func BinaryRipemd160(o interface{}) []byte { - hasher, n, err := ripemd160.New(), new(int), new(error) - WriteBinary(o, hasher, n, err) - if *err != nil { - cmn.PanicSanity(*err) - } - return hasher.Sum(nil) -}