   "Syncs the node list with the backing node pool."
   []
   (locking refresh-nodes-lock
-    (let [nodes (to-set (node-pools/get-nodes node-pool))
+    (let [nodes (to-set (node-pools/get-nodes (node-pool config)))
           registered-nodes (to-set (map #(get % :url) (view-models)))]
       (doall
         (concat

    (car/watch node-set-key)
    (try
      (let [url (get (view-model id) :url)]
        (if (some #{url} (node-pools/get-nodes node-pool))
          (node-pools/remove-node node-pool url)))
      (finally
        (car/srem node-set-key id)
        (car/del (node-key id))


(deftype ConfigNodePool [])


(def node-pool
  "Return a node pool given a config function.

  The config function should expect a single keyword argument and to look up
  config values.

  Note that, though this function isn't referentially transparent, it's
  memoized. This is a hack, and will be cleaned up when we start using
  components (https://github.com/cardforcoin/shale/issues/58)."
  (memoize
    (fn [config-fn]
      (if (nil? (config-fn :node-pool-impl))
        (if (nil? (config-fn :node-pool-cloud-config))
          (node-pools/DefaultNodePool. (or (config-fn :node-list)
                                           ["http://localhost:5555/wd/hub"]))
          (if (= ((config-fn :node-pool-cloud-config) :provider) :aws)
            (node-pools/AWSNodePool. (config :node-pool-cloud-config))
            (throw (ex-info (str "Issue with cloud config: AWS is "
                                 "the only currently supported "
                                 "provider.")
                            {:user-visible true :status 500}))))
        (do
          (extend ConfigNodePool
            node-pools/INodePool
            (config-fn :node-pool-impl))
          (ConfigNodePool.))))))

(def default-session-limit
  (or (config :node-max-sessions) 3))
