       reader  (reader)
       :else   (throw (IOException.
                         (str "Cannot open empty block " (:id block)))))))
-
-
-(defn from-file
-  "Creates a lazy block from a local file. The file is read once to calculate
-  the identifier."
-  ([file]
-   (from-file file :sha2-256))
-  ([file algorithm]
-   (let [file (io/file file)
-         hash-fn (data/checked-hash algorithm)
-         reader #(io/input-stream file)
-         id (hash-fn (reader))]
-     (data/lazy-block id (.length file) reader))))
 
 
 (defn read!


;; ## Utility Functions

(defn select-hashes
  "Selects multihash identifiers from a sequence based on some criteria.

  Available options:

  - `:algorithm`  only return hashes using this algorithm
  - `:after`      start enumerating ids lexically following this string
  - `:limit`      return at most 'limit' hashes
  "
  [opts ids]
  ; TODO: this is an awkward way to search the store, think of a better approach
  (let [{:keys [algorithm prefix encoder], :or {encoder multihash/hex}} opts
        after (:after opts prefix)]
    (cond->> ids
      algorithm  (filter #(= algorithm (:algorithm %)))
      after      (drop-while #(pos? (compare after (encoder %))))
      prefix     (take-while #(.startsWith ^String (encoder %) prefix)))))


(defn scan-size

    multihash.core.Multihash))


;; ## Block IO

(defn from-file
  "Creates a lazy block from a local file. The file is read once to calculate
  the identifier."
  ([file]
   (from-file file :sha2-256))
  ([file algorithm]
   (let [file (io/file file)
         hash-fn (data/checked-hash algorithm)
         reader #(io/input-stream file)
         id (hash-fn (reader))]
     (data/lazy-block id (.length file) reader))))


(defn open
