      x
      (parse-address (str x))))
   ([algorithm digest]
+   (assert-valid-digest algorithm)
    (BlobRef. algorithm digest)))

  (into #{} (keys digest-functions)))



;; BLOB REFERENCE


(defn hash-content
  "Calculates the blob reference for the given content."
  [algorithm content]
  (assert-valid-digest algorithm)
  (let [hashfn (digest-functions algorithm)]
    (BlobRef. algorithm (-> content hashfn .toLowerCase))))


(defn parse-address
  "Parses an address string into a blobref. Accepts either a hash URN or the
  shorter \"algo:address\" format."
  [address]
  (let [address (if (re-find #"^urn:" address) (subs address 4) address)
        address (if (re-find #"^hash:" address) (subs address 5) address)
        [algorithm digest] (string/split address #":" 2)]
    (assert-valid-digest algorithm)
    (BlobRef. (keyword algorithm) digest)))


