remove semaphores

This commit is contained in:
yenda 2019-08-23 22:28:44 +02:00
parent d4a396bedf
commit b28c521b2b
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
6 changed files with 3 additions and 53 deletions

View File

@ -698,11 +698,6 @@
(fn [cofx _] (fn [cofx _]
(protocol/handle-close-app-confirmed cofx))) (protocol/handle-close-app-confirmed cofx)))
(handlers/register-handler-fx
:protocol/state-sync-timed-out
(fn [cofx _]
(protocol/check-sync-state cofx)))
;; notifications module ;; notifications module
(handlers/register-handler-fx (handlers/register-handler-fx

View File

@ -9,9 +9,9 @@
[status-im.transport.core :as transport] [status-im.transport.core :as transport]
[status-im.tribute-to-talk.core :as tribute-to-talk] [status-im.tribute-to-talk.core :as tribute-to-talk]
[status-im.utils.fx :as fx] [status-im.utils.fx :as fx]
[status-im.utils.semaphores :as semaphores]
[status-im.utils.utils :as utils])) [status-im.utils.utils :as utils]))
;;TODO move this logic to status-go
(fx/defn update-sync-state (fx/defn update-sync-state
[{{:keys [sync-state sync-data] :as db} :db} error sync] [{{:keys [sync-state sync-data] :as db} :db} error sync]
(let [{:keys [highestBlock currentBlock] :as state} (let [{:keys [highestBlock currentBlock] :as state}
@ -39,30 +39,6 @@
(update-sync-state error sync) (update-sync-state error sync)
(node/update-sync-state error sync))) (node/update-sync-state error sync)))
(fx/defn check-sync-state
[{:keys [db] :as cofx}]
(if (:multiaccount db)
{::json-rpc/call
[{:method "eth_syncing"
:on-success
(fn [sync]
(re-frame/dispatch [:ethereum.callback/get-syncing-success nil sync]))
:on-error
(fn [error]
(re-frame/dispatch [:ethereum.callback/get-syncing-success error nil]))}]
:utils/dispatch-later [{:ms 10000
:dispatch [:protocol/state-sync-timed-out]}]}
(semaphores/free cofx :check-sync-state?)))
(fx/defn start-check-sync-state
[{{:keys [:networks/current-network :networks/networks] :as db} :db :as cofx}]
(when (and (not (semaphores/locked? cofx :check-sync-state?))
(not (ethereum/network-with-upstream-rpc?
(get networks current-network))))
(fx/merge cofx
(check-sync-state)
(semaphores/lock :check-sync-state?))))
(fx/defn initialize-protocol (fx/defn initialize-protocol
[{:data-store/keys [mailserver-topics mailservers] [{:data-store/keys [mailserver-topics mailservers]
:keys [db] :as cofx}] :keys [db] :as cofx}]
@ -87,7 +63,6 @@
:fetched-network-id fetched-network-id}) :fetched-network-id fetched-network-id})
#(re-frame/dispatch [:protocol.ui/close-app-confirmed]))))}]} #(re-frame/dispatch [:protocol.ui/close-app-confirmed]))))}]}
(tribute-to-talk/init) (tribute-to-talk/init)
(start-check-sync-state)
(mailserver/initialize-ranges) (mailserver/initialize-ranges)
(mailserver/initialize-mailserver mailservers) (mailserver/initialize-mailserver mailservers)
(transport/init-whisper)))) (transport/init-whisper))))

View File

@ -38,7 +38,6 @@
:node-info {} :node-info {}
:peers-summary [] :peers-summary []
:notifications {} :notifications {}
:semaphores #{}
:my-profile/editing? false :my-profile/editing? false
:transport/filters {} :transport/filters {}
:transport/message-envelopes {} :transport/message-envelopes {}
@ -174,8 +173,6 @@
;; PUSH NOTIFICATIONS ;; PUSH NOTIFICATIONS
(spec/def :push-notifications/stored (spec/nilable map?)) (spec/def :push-notifications/stored (spec/nilable map?))
(spec/def ::semaphores set?)
(spec/def ::hardwallet (spec/nilable map?)) (spec/def ::hardwallet (spec/nilable map?))
(spec/def :stickers/packs (spec/nilable map?)) (spec/def :stickers/packs (spec/nilable map?))
@ -287,7 +284,6 @@
::chain ::chain
::app-state ::app-state
::app-in-background-since ::app-in-background-since
::semaphores
::hardwallet ::hardwallet
:multiaccount/multiaccount :multiaccount/multiaccount
:navigation/view-id :navigation/view-id

View File

@ -1,14 +0,0 @@
(ns status-im.utils.semaphores
(:require [status-im.utils.fx :as fx]))
(fx/defn lock [{:keys [db]} semaphore]
#_{:pre [(keyword? semaphore)]}
{:db (update db :semaphores conj semaphore)})
(fx/defn free [{:keys [db]} semaphore]
#_{:pre [(keyword? semaphore)]}
{:db (update db :semaphores disj semaphore)})
(defn locked? [{:keys [db]} semaphore]
#_{:pre [(keyword? semaphore)]}
((get db :semaphores) semaphore))

View File

@ -28,8 +28,7 @@
(testing ":accounts.login.callback/login-success event received." (testing ":accounts.login.callback/login-success event received."
(let [db {:multiaccounts/login {:address "address" (let [db {:multiaccounts/login {:address "address"
:password "password"} :password "password"}
:multiaccount data/multiaccount :multiaccount data/multiaccount}
:semaphores #{}}
cofx {:db db cofx {:db db
:data-store/mailservers [] :data-store/mailservers []
:data-store/mailserver-topics data/topics} :data-store/mailserver-topics data/topics}

View File

@ -6,8 +6,7 @@
[status-im.transport.message.core :as message])) [status-im.transport.message.core :as message]))
(deftest init-whisper (deftest init-whisper
(let [cofx {:db {:multiaccount {:public-key "1"} (let [cofx {:db {:multiaccount {:public-key "1"}}}]
:semaphores #{}}}]
(testing "custom mailservers" (testing "custom mailservers"
(let [ms-1 {:id "1" (let [ms-1 {:id "1"
:fleet :eth.beta :fleet :eth.beta