       (do (log/info
            (format "Copied %s to %s." remote-path local-path))
           (transfer/rcopy remote-fs remote-path local-path
-                        :throttle throttle)
+                          :throttle throttle)
           (log/info
            (format "Copied %s to %s." remote-path local-path)))
       (do (log/info

  "Transfers the supplied version from the domain's remote store to
  its local store. To throttle the download, provide a throttling
  agent with the optional `:throttle` keyword argument."
  [domain version & {:keys [throttle]}]
  (let [{:keys [local-store remote-store]} domain]
    (.createVersion local-store version)
    (u/do-pmap (partial transfer-shard! domain version)
               (shard-set domain))

  (shard/prioritize-hosts shard-index
                          (key->shard domain key)
                          #{hostname}))


(defn memory-persistence []
  (let [state (atom {})]
    (reify Persistence
      (index [this doc]
        (swap! state assoc (.key doc) (.val doc)))
      (iterator [this]
        (map (fn [[k v]] (KeyValDocument. k v))
             @state))
      (close [_]))))

(defn memory-coordinator []
  (let [state (atom {})]
    (reify Coordinator
      (openPersistenceForRead [this root opts]
        (or (get @state root)
            (let [fresh (memory-persistence)]
              (swap! state assoc root fresh)
              fresh))))))

;; ## Type Versions
;;
;; TODO -- convert to KeyValPersistence

(deftype MemoryPersistence [state]
  Persistence
  (index [{:keys [state]} doc]
    (swap! state assoc (.key doc) (.val doc)))
  (iterator [{:keys [state]}]
    (map (fn [[k v]] (KeyValDocument. k v))
         @state))
  (close [_]))

(deftype MemoryCoordinator [state]
  Coordinator
  (openPersistenceForRead
    [{:keys [state]} root opts]
    (or (get @state root)
        (let [fresh (memory-persistence)]
          (swap! state assoc root fresh)
          fresh))))


