diff --git a/blockstore/idstore.go b/blockstore/idstore.go index 2a5bf8415..477da70b2 100644 --- a/blockstore/idstore.go +++ b/blockstore/idstore.go @@ -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