[#10197] More retries when requesting balances
This commit is contained in:
parent
c9cdd48849
commit
3760d2a2e5
|
@ -7,7 +7,8 @@
|
||||||
[status-im.native-module.core :as status]
|
[status-im.native-module.core :as status]
|
||||||
[status-im.utils.money :as money]
|
[status-im.utils.money :as money]
|
||||||
[status-im.utils.types :as types]
|
[status-im.utils.types :as types]
|
||||||
[taoensso.timbre :as log]))
|
[taoensso.timbre :as log]
|
||||||
|
[status-im.utils.utils :as utils]))
|
||||||
|
|
||||||
(def json-rpc-api
|
(def json-rpc-api
|
||||||
{"eth_call" {}
|
{"eth_call" {}
|
||||||
|
@ -171,11 +172,20 @@
|
||||||
"mailservers_getChatRequestRanges" {}
|
"mailservers_getChatRequestRanges" {}
|
||||||
"mailservers_deleteChatRequestRange" {}})
|
"mailservers_deleteChatRequestRange" {}})
|
||||||
|
|
||||||
(defn on-error-retry [call-method {:keys [method number-of-retries on-error] :as arg}]
|
(defn on-error-retry
|
||||||
|
[call-method {:keys [method number-of-retries delay on-error] :as arg}]
|
||||||
(if (pos? number-of-retries)
|
(if (pos? number-of-retries)
|
||||||
(fn []
|
(fn []
|
||||||
(log/debug "[on-error-retry]" method "number-of-retries" number-of-retries)
|
(let [updated-delay (if delay
|
||||||
(call-method (update arg :number-of-retries dec)))
|
(min 2000 (* 2 delay))
|
||||||
|
50)]
|
||||||
|
(log/debug "[on-error-retry]" method
|
||||||
|
"number-of-retries" number-of-retries
|
||||||
|
"delay" delay)
|
||||||
|
(utils/set-timeout #(call-method (-> arg
|
||||||
|
(update :number-of-retries dec)
|
||||||
|
(assoc :delay updated-delay)))
|
||||||
|
updated-delay)))
|
||||||
on-error))
|
on-error))
|
||||||
|
|
||||||
(defn call-ext-method [waku-enabled? method]
|
(defn call-ext-method [waku-enabled? method]
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
{:method "eth_getBalance"
|
{:method "eth_getBalance"
|
||||||
:params [address "latest"]
|
:params [address "latest"]
|
||||||
:on-success on-success
|
:on-success on-success
|
||||||
:number-of-retries 4
|
:number-of-retries 50
|
||||||
:on-error on-error}))
|
:on-error on-error}))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
|
@ -180,7 +180,7 @@
|
||||||
(json-rpc/call
|
(json-rpc/call
|
||||||
{:method "wallet_getTokensBalances"
|
{:method "wallet_getTokensBalances"
|
||||||
:params [addresses (keys tokens)]
|
:params [addresses (keys tokens)]
|
||||||
:number-of-retries 4
|
:number-of-retries 50
|
||||||
:on-success
|
:on-success
|
||||||
(fn [results]
|
(fn [results]
|
||||||
(when-let [balances (clean-up-results results tokens (if init? nil assets))]
|
(when-let [balances (clean-up-results results tokens (if init? nil assets))]
|
||||||
|
|
Loading…
Reference in New Issue