[#9987] Stop fetching new blocks while app is not active

This commit is contained in:
Roman Volosovskyi 2020-03-03 15:48:51 +02:00
parent c2e195979c
commit cc520a1f27
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 12 additions and 9 deletions

View File

@ -210,23 +210,26 @@
(fx/defn new-transfers (fx/defn new-transfers
{:events [::new-transfers]} {:events [::new-transfers]}
[{:keys [db] :as cofx} transfers {:keys [address historical? limit]}] [{:keys [db] :as cofx} transfers {:keys [address limit]}]
(log/debug "[transfers] new-transfers" (log/debug "[transfers] new-transfers"
"address" address "address" address
"count" (count transfers) "count" (count transfers)
"limit" limit) "limit" limit)
(let [checksum (eip55/address->checksum address) (let [checksum (eip55/address->checksum address)
min-known-block (or (get-min-known-block db address)
(:ethereum/current-block db))
effects (cond-> [(when (seq transfers) effects (cond-> [(when (seq transfers)
(set-lowest-fetched-block checksum transfers))] (set-lowest-fetched-block checksum transfers))]
(seq transfers) (seq transfers)
(concat (mapv add-transfer transfers)) (concat (mapv add-transfer transfers))
;;NOTE: we only update the balance for new transfers and not
;; historical ones true
(not historical?)
(conj (wallet/update-balances (conj (wallet/update-balances
(into [] (reduce (fn [acc {:keys [address]}] (into [] (reduce (fn [acc {:keys [address block]}]
(conj acc address)) (if (> block min-known-block)
(conj acc address)
acc))
#{} #{}
transfers)))) transfers))))

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead", "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.48.3", "version": "v0.48.8",
"commit-sha1": "7be1fcb978ad3a640b9eb6372eea4caf4e1bfb03", "commit-sha1": "d1beb4c76d9fabcd00da75ad63430104f92c1404",
"src-sha256": "100dls7fcddcfziw1rhdb2aaj0lpwi2ri6bnr503sxbjaac1zmnb" "src-sha256": "0sx85hg5c1dap2cnf44kqgp0lbknl4wd3n47cchiivnlmv4c9gw8"
} }