From e8b3ca8cae2bffb0cc879b4d32064e196bfe14eb Mon Sep 17 00:00:00 2001 From: SpideyPool192 Date: Thu, 18 Aug 2022 15:02:53 +0530 Subject: [PATCH] use ipdl prime in 'helpers.go/GetCid' --- x/nameservice/helpers/helpers.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/x/nameservice/helpers/helpers.go b/x/nameservice/helpers/helpers.go index 2864315f..f2f4ed5d 100644 --- a/x/nameservice/helpers/helpers.go +++ b/x/nameservice/helpers/helpers.go @@ -7,9 +7,9 @@ import ( "encoding/gob" "encoding/hex" "encoding/json" + set "github.com/deckarep/golang-set" - cbor "github.com/ipfs/go-ipld-cbor" - mh "github.com/multiformats/go-multihash" + wnsUtils "github.com/tharsis/ethermint/utils" "sort" ) @@ -72,12 +72,7 @@ func UnMarshalMapFromJSONBytes(bytes []byte) map[string]interface{} { // GetCid gets the content ID. func GetCid(content []byte) (string, error) { - node, err := cbor.FromJSON(bytes.NewReader(content), mh.SHA2_256, -1) - if err != nil { - return "", err - } - - return node.Cid().String(), nil + return wnsUtils.CIDFromJSONBytesUsingIpldPrime(content) } // BytesToBase64 encodes a byte array as a base64 string.