[Fix #2683] Do not run sync state loop on upstream RPC networks
This commit is contained in:
parent
5206f297cf
commit
3e8ce2d6d7
|
@ -15,7 +15,8 @@
|
||||||
[taoensso.timbre :as log :refer-macros [debug]]
|
[taoensso.timbre :as log :refer-macros [debug]]
|
||||||
[status-im.native-module.core :as status]
|
[status-im.native-module.core :as status]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[status-im.utils.web3-provider :as web3-provider]))
|
[status-im.utils.web3-provider :as web3-provider]
|
||||||
|
[status-im.utils.ethereum.core :as utils]))
|
||||||
|
|
||||||
;;;; COFX
|
;;;; COFX
|
||||||
|
|
||||||
|
@ -302,8 +303,9 @@
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:initialize-sync-listener
|
:initialize-sync-listener
|
||||||
(fn [{{:keys [sync-listening-started] :as db} :db} _]
|
(fn [{{:keys [sync-listening-started network networks/networks] :as db} :db} _]
|
||||||
(when-not sync-listening-started
|
(when (and (not sync-listening-started)
|
||||||
|
(not (utils/network-with-upstream-rpc? networks network)))
|
||||||
{:db (assoc db :sync-listening-started true)
|
{:db (assoc db :sync-listening-started true)
|
||||||
:dispatch [:check-sync]})))
|
:dispatch [:check-sync]})))
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
[status-im.data-store.networks :as networks]
|
[status-im.data-store.networks :as networks]
|
||||||
[status-im.ui.screens.network-settings.navigation]
|
[status-im.ui.screens.network-settings.navigation]
|
||||||
[status-im.ui.screens.accounts.events :as accounts-events]
|
[status-im.ui.screens.accounts.events :as accounts-events]
|
||||||
[status-im.i18n :as i18n]))
|
[status-im.i18n :as i18n]
|
||||||
|
[status-im.utils.ethereum.core :as utils]))
|
||||||
|
|
||||||
;;;; FX
|
;;;; FX
|
||||||
|
|
||||||
|
@ -28,9 +29,6 @@
|
||||||
(assoc :new-networks (vals new-networks')))
|
(assoc :new-networks (vals new-networks')))
|
||||||
:save-networks new-networks'})))
|
:save-networks new-networks'})))
|
||||||
|
|
||||||
(defn network-with-upstream-rpc? [networks network]
|
|
||||||
(get-in networks [network :raw-config :UpstreamConfig :Enabled]))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
::save-network
|
::save-network
|
||||||
(fn [{:keys [db now]} [_ network]]
|
(fn [{:keys [db now]} [_ network]]
|
||||||
|
@ -44,7 +42,7 @@
|
||||||
(fn [{:keys [db now]} [_ network]]
|
(fn [{:keys [db now]} [_ network]]
|
||||||
(let [current-network (:network db)
|
(let [current-network (:network db)
|
||||||
networks (:networks/networks db)]
|
networks (:networks/networks db)]
|
||||||
(if (network-with-upstream-rpc? networks current-network)
|
(if (utils/network-with-upstream-rpc? networks current-network)
|
||||||
(merge (accounts-events/account-update {:db db} {:network network
|
(merge (accounts-events/account-update {:db db} {:network network
|
||||||
:last-updated now})
|
:last-updated now})
|
||||||
{:dispatch [:navigate-to-clean :accounts]
|
{:dispatch [:navigate-to-clean :accounts]
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
(defn testnet? [id]
|
(defn testnet? [id]
|
||||||
(contains? #{(chain-id :ropsten) (chain-id :rinkeby)} id))
|
(contains? #{(chain-id :ropsten) (chain-id :rinkeby)} id))
|
||||||
|
|
||||||
|
(defn network-with-upstream-rpc? [networks network]
|
||||||
|
(get-in networks [network :raw-config :UpstreamConfig :Enabled]))
|
||||||
|
|
||||||
(def hex-prefix "0x")
|
(def hex-prefix "0x")
|
||||||
|
|
||||||
(defn normalized-address [address]
|
(defn normalized-address [address]
|
||||||
|
|
Loading…
Reference in New Issue