RefFromHash returns a blobref representing the given hash. It panics if the hash isn't of a known type.
(h hash.Hash)
| 420 | // RefFromHash returns a blobref representing the given hash. |
| 421 | // It panics if the hash isn't of a known type. |
| 422 | func 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. |