  :mailserver/update-mailservers
  (fn [enodes]
    (update-mailservers! enodes)))
+
+(re-frame/reg-fx
+ :mailserver/set-limit
+ (fn [n]
+   (reset! limit n)))
+
+(defn decrease-limit []
+  (max min-limit (/ @limit 2)))
+
+(defn increase-limit []
+  (min max-limit (* @limit 2)))
 
 (defn mark-trusted-peer! [web3 enode]
   (.markTrustedPeer (transport.utils/shh web3)

    (fx/merge cofx
              {:db (update db :mailserver/current-request dissoc :attemps)}
              (change-mailserver))
    (when-let [mailserver (get-mailserver-when-ready cofx)]
      (let [{:keys [topics from to cursor] :as request} (get db :mailserver/current-request)
            web3 (:web3 db)]
        (log/info "mailserver: message request " request-id "expired for mailserver topic" topics "from" from "to" to "cursor" cursor)
        {:db (update-in db [:mailserver/current-request :attemps] inc)
         :mailserver/request-messages {:web3    web3
                                       :mailserver   mailserver
                                       :request request}}))))

(fx/defn initialize-mailserver
  [cofx custom-mailservers]
  (fx/merge cofx
            (add-custom-mailservers custom-mailservers)
            (set-current-mailserver)))


  (when (accounts.db/logged-in? cofx)
    (let [error (:errorMessage event)]
      (if (empty? error)
        (fx/merge
         cofx
         {:mailserver/set-limit (increase-limit)}
         (update-mailserver-topics {:request-id (:requestID event)
                                    :cursor     (:cursor event)}))

        (handle-request-error cofx error)))))

(fx/defn show-request-error-popup
