diff --git a/cid.go b/cid.go index 2c4fd22..f0d3a8f 100644 --- a/cid.go +++ b/cid.go @@ -185,10 +185,12 @@ func NewCidV1(codecType uint64, mhash mh.Multihash) Cid { return Cid{string(buf[:n+hashlen])} } -var _ encoding.BinaryMarshaler = Cid{} -var _ encoding.BinaryUnmarshaler = (*Cid)(nil) -var _ encoding.TextMarshaler = Cid{} -var _ encoding.TextUnmarshaler = (*Cid)(nil) +var ( + _ encoding.BinaryMarshaler = Cid{} + _ encoding.BinaryUnmarshaler = (*Cid)(nil) + _ encoding.TextMarshaler = Cid{} + _ encoding.TextUnmarshaler = (*Cid)(nil) +) // Cid represents a self-describing content addressed // identifier. It is formed by a Version, a Codec (which indicates @@ -564,7 +566,7 @@ type Prefix struct { // and return a newly constructed Cid with the resulting multihash. func (p Prefix) Sum(data []byte) (Cid, error) { length := p.MhLength - if p.MhType == mh.ID { + if p.MhType == mh.IDENTITY { length = -1 } diff --git a/cid_fuzz.go b/cid_fuzz.go index 99842b5..0bdd7e6 100644 --- a/cid_fuzz.go +++ b/cid_fuzz.go @@ -4,7 +4,6 @@ package cid func Fuzz(data []byte) int { cid, err := Cast(data) - if err != nil { return 0 } diff --git a/cid_test.go b/cid_test.go index 159ded8..28fc964 100644 --- a/cid_test.go +++ b/cid_test.go @@ -82,7 +82,7 @@ func TestPrefixSum(t *testing.T) { // Test creating CIDs both manually and with Prefix. // Tests: https://github.com/ipfs/go-cid/issues/83 for _, hashfun := range []uint64{ - mh.ID, mh.SHA3, mh.SHA2_256, + mh.IDENTITY, mh.SHA3, mh.SHA2_256, } { h1, err := mh.Sum([]byte("TEST"), hashfun, -1) if err != nil { @@ -388,7 +388,6 @@ func TestNewPrefixV0(t *testing.T) { if c1.Prefix() != c2.Prefix() { t.Fatal("prefixes mismatch") } - } func TestInvalidV0Prefix(t *testing.T) { @@ -512,13 +511,13 @@ func TestParse(t *testing.T) { } assertions := [][]interface{}{ - []interface{}{NewCidV0(h), theHash}, - []interface{}{NewCidV0(h).Bytes(), theHash}, - []interface{}{h, theHash}, - []interface{}{theHash, theHash}, - []interface{}{"/ipfs/" + theHash, theHash}, - []interface{}{"https://ipfs.io/ipfs/" + theHash, theHash}, - []interface{}{"http://localhost:8080/ipfs/" + theHash, theHash}, + {NewCidV0(h), theHash}, + {NewCidV0(h).Bytes(), theHash}, + {h, theHash}, + {theHash, theHash}, + {"/ipfs/" + theHash, theHash}, + {"https://ipfs.io/ipfs/" + theHash, theHash}, + {"http://localhost:8080/ipfs/" + theHash, theHash}, } assert := func(arg interface{}, expected string) error { diff --git a/go.sum b/go.sum index b7d4586..f8fe8a9 100644 --- a/go.sum +++ b/go.sum @@ -2,7 +2,6 @@ github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0 github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771 h1:MHkK1uRtFbVqvAgvWxafZe54+5uBxLluGylDiKgdhwo= github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= -github.com/mr-tron/base58 v1.1.0 h1:Y51FGVJ91WBqCEabAi5OPUz38eAx8DakuAm5svLcsfQ= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc= github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= @@ -12,11 +11,10 @@ github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ8 github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk= github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= -github.com/multiformats/go-multihash v0.0.13 h1:06x+mk/zj1FoMsgNejLpy6QTvJqlSt/BhLEy87zidlc= -github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= +github.com/multiformats/go-multihash v0.0.14 h1:QoBceQYQQtNUuf6s7wHxnE2c8bhbMqhfGzNI032se/I= github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= -github.com/multiformats/go-varint v0.0.5 h1:XVZwSo04Cs3j/jS0uAEPpT3JY6DzMcVLLoWOSnCxOjg= github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= +github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=