[#10197] More retries when requesting balances

This commit is contained in:
Roman Volosovskyi 2020-03-25 17:10:10 +02:00
parent c9cdd48849
commit 3760d2a2e5
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 16 additions and 6 deletions

View File

@ -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]

View File

@ -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))]