MCPcopy
hub / github.com/perkeep/perkeep / RefFromHash

Function RefFromHash

pkg/blob/ref.go:422–428  ·  view source on GitHub ↗

RefFromHash returns a blobref representing the given hash. It panics if the hash isn't of a known type.

(h hash.Hash)

Source from the content-addressed store, hash-verified

420// RefFromHash returns a blobref representing the given hash.
421// It panics if the hash isn't of a known type.
422func RefFromHash(h hash.Hash) Ref {
423 meta, ok := metaFromType[hashSig{reflect.TypeOf(h), h.Size()}]
424 if !ok {
425 panic(fmt.Sprintf("Currently-unsupported hash type %T", h))
426 }
427 return Ref{meta.ctor(h.Sum(nil))}
428}
429
430// RefFromString returns a blobref from the given string, for the currently
431// recommended hash function.

Callers 15

wholeRefMethod · 0.92
updatePhotoMethod · 0.92
updatePhotoInAlbumMethod · 0.92
testSizedBlobFunction · 0.92
TestPackNormalFunction · 0.92
TestPackLargeFunction · 0.92
TestReindexFunction · 0.92
testOpenWholeRefMethod · 0.92
TestPackerBoundarySplitsFunction · 0.92
packMethod · 0.92
writeAZipMethod · 0.92
BlobRefMethod · 0.92

Calls 2

SumMethod · 0.80
SizeMethod · 0.65

Tested by 6

TestPackNormalFunction · 0.74
TestPackLargeFunction · 0.74
TestReindexFunction · 0.74
testOpenWholeRefMethod · 0.74
TestPackerBoundarySplitsFunction · 0.74
SumMethod · 0.74