Skip to content

Commit 3b36077

Browse files
Merge pull request ipfs/go-ipfs-blockstore#73 from ipfs/fix-staticcheck
fix staticcheck This commit was moved from ipfs/go-ipfs-blockstore@12cea36
2 parents e74b9b5 + 9255102 commit 3b36077

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

blockstore/idstore.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func extractContents(k cid.Cid) (bool, []byte) {
3434
}
3535

3636
dmh, err := mh.Decode(k.Hash())
37-
if err != nil || dmh.Code != mh.ID {
37+
if err != nil || dmh.Code != mh.IDENTITY {
3838
return false, nil
3939
}
4040
return true, dmh.Digest

blockstore/idstore_test.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func createTestStores() (Blockstore, *callbackDatastore) {
1717
}
1818

1919
func TestIdStore(t *testing.T) {
20-
idhash1, _ := cid.NewPrefixV1(cid.Raw, mh.ID).Sum([]byte("idhash1"))
20+
idhash1, _ := cid.NewPrefixV1(cid.Raw, mh.IDENTITY).Sum([]byte("idhash1"))
2121
idblock1, _ := blk.NewBlockWithCid([]byte("idhash1"), idhash1)
2222
hash1, _ := cid.NewPrefixV1(cid.Raw, mh.SHA2_256).Sum([]byte("hash1"))
2323
block1, _ := blk.NewBlockWithCid([]byte("hash1"), hash1)
@@ -110,7 +110,7 @@ func TestIdStore(t *testing.T) {
110110
t.Fatal(err)
111111
}
112112

113-
idhash2, _ := cid.NewPrefixV1(cid.Raw, mh.ID).Sum([]byte("idhash2"))
113+
idhash2, _ := cid.NewPrefixV1(cid.Raw, mh.IDENTITY).Sum([]byte("idhash2"))
114114
idblock2, _ := blk.NewBlockWithCid([]byte("idhash2"), idhash2)
115115
hash2, _ := cid.NewPrefixV1(cid.Raw, mh.SHA2_256).Sum([]byte("hash2"))
116116
block2, _ := blk.NewBlockWithCid([]byte("hash2"), hash2)
@@ -146,10 +146,13 @@ func TestIdStore(t *testing.T) {
146146
}
147147

148148
ch, err := ids.AllKeysChan(context.TODO())
149+
if err != nil {
150+
t.Fatal(err)
151+
}
149152
cnt := 0
150153
for c := range ch {
151154
cnt++
152-
if c.Prefix().MhType == mh.ID {
155+
if c.Prefix().MhType == mh.IDENTITY {
153156
t.Fatalf("block with identity hash found in blockstore")
154157
}
155158
}

0 commit comments

Comments
 (0)