[#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.utils.money :as money]
|
||||
[status-im.utils.types :as types]
|
||||
[taoensso.timbre :as log]))
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.utils :as utils]))
|
||||
|
||||
(def json-rpc-api
|
||||
{"eth_call" {}
|
||||
|
@ -171,11 +172,20 @@
|
|||
"mailservers_getChatRequestRanges" {}
|
||||
"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)
|
||||
(fn []
|
||||
(log/debug "[on-error-retry]" method "number-of-retries" number-of-retries)
|
||||
(call-method (update arg :number-of-retries dec)))
|
||||
(let [updated-delay (if delay
|
||||
(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))
|
||||
|
||||
(defn call-ext-method [waku-enabled? method]
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
{:method "eth_getBalance"
|
||||
:params [address "latest"]
|
||||
:on-success on-success
|
||||
:number-of-retries 4
|
||||
:number-of-retries 50
|
||||
:on-error on-error}))
|
||||
|
||||
(re-frame/reg-fx
|
||||
|
@ -180,7 +180,7 @@
|
|||
(json-rpc/call
|
||||
{:method "wallet_getTokensBalances"
|
||||
:params [addresses (keys tokens)]
|
||||
:number-of-retries 4
|
||||
:number-of-retries 50
|
||||
:on-success
|
||||
(fn [results]
|
||||
(when-let [balances (clean-up-results results tokens (if init? nil assets))]
|
||||
|
|
Loading…
Reference in New Issue