 (defn- apply-commit-index [state]
   (if (> (:commit-index state) (:last-applied state))
     (-> (update state :last-applied inc)
-        (update :db #(apply-entry state %)))
+        (update :db #(log/apply-entry state %)))
     state))
 
 (defn- redirect-to-leader [state p]

  (->
   (update state :election-timeout - dt)
   (apply-commit-index)
   (utils/if-not-leader? check-election-timeout)
   (process-rx-packets)
   (utils/if-leader? check-backlog dt)
   (utils/if-leader? cs/check-clients)))

(defn set-peers [state peers]

            (and (= :candidate (:type state))
                 (= :append-entries (:type params))
                 (<= (:current-term state) (:term body))))
      (f/become-follower (assoc state :current-term (:term body))
                         (:leader-id body))
      (if (:leader-id body)
        (assoc state :leader-id (:leader-id body))
        state))))
