Skip to content

Commit

Permalink
Merge pull request ipfs/go-ipfs-blockstore#56 from ipfs/feat/optimize…
Browse files Browse the repository at this point in the history
…-get

Optimize id store

This commit was moved from ipfs/go-ipfs-blockstore@9283acf
  • Loading branch information
Stebalien committed Jul 24, 2020
2 parents 59a94b0 + f240acc commit 911964f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions blockstore/idstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ func NewIdStore(bs Blockstore) Blockstore {
}

func extractContents(k cid.Cid) (bool, []byte) {
// Pre-check by calling Prefix(), this much faster than extracting the hash.
if k.Prefix().MhType != mh.IDENTITY {
return false, nil
}

dmh, err := mh.Decode(k.Hash())
if err != nil || dmh.Code != mh.ID {
return false, nil
Expand Down

0 comments on commit 911964f

Please sign in to comment.