OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / vendor / github.com / tendermint / go-wire / util.go
index 4e20619..751f4bf 100644 (file)
@@ -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)
-}