 
 (defn purge-nodes!
   "Delete nodes which have been *deactivated* longer than `node-purge-ttl`."
-  [db node-purge-ttl]
+  [node-purge-ttl db]
   {:pre [(map? db)
          (period? node-purge-ttl)]}
   (try


      ;; Pretty much this helper just knows our job-pool and gc-interval
      (let [gc-interval-millis (to-millis gc-interval)
            gc-task (fn [f & args] (apply interspaced gc-interval-millis f job-pool args))]

        (gc-task #(garbage-collect! db))

        (when (pos? (to-secs dlo-compression-threshold))
          (gc-task #(compress-dlo! discard-dir dlo-compression-threshold)))

        ;; We splay these a bit to hopefully reduce DB contention.
        (when (pos? (to-secs node-ttl))
          (gc-task #(auto-deactivate-nodes! db node-ttl) :initial-delay (* gc-interval-millis 1/4)))

        (when (pos? (to-secs node-purge-ttl))
          (gc-task #(purge-nodes! db node-purge-ttl) :initial-delay (* gc-interval-millis 2/4)))

        (when (pos? (to-secs report-ttl))
          (gc-task #(sweep-reports! db report-ttl) :initial-delay (* gc-interval-millis 3/4))))

      ;; Start debug REPL if necessary
      (let [{:keys [enabled type host port] :or {type "nrepl" host "localhost"}} (:repl config)]

        (scf-store/garbage-collect!)))
    (catch Exception e
      (log/error e "Error during garbage collection"))))

(defn perform-db-maintenance!
  "Runs the full set of database maintenance tasks in `fns` on `db` in order.
  Has no error-handling of its own, so all `fns` must handle their own errors.
  The purpose of this function is primarily to serialize these tasks, to avoid
  concurrent long-running database tasks."
  [db & fns]
  {:pre [(map? db)]}
  (doseq [f fns]
    (f db)))

(defn check-for-updates
  "This will fetch the latest version number of PuppetDB and log if the system
