mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-02 20:05:09 +00:00
remove code related to restarting RPC server on entering background (#2008)
* remove restart-rpc-server, stop-rpc-server, start-rpc-server functions and related code * clean native code
This commit is contained in:
parent
cede095746
commit
a7950af335
@ -320,42 +320,6 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
|
||||||
public void startNodeRPCServer() {
|
|
||||||
Log.d(TAG, "startNodeRPCServer");
|
|
||||||
final Activity activity = getCurrentActivity();
|
|
||||||
if (activity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread thread = new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Statusgo.StartNodeRPCServer();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ReactMethod
|
|
||||||
public void stopNodeRPCServer() {
|
|
||||||
Log.d(TAG, "stopNodeRPCServer");
|
|
||||||
final Activity activity = getCurrentActivity();
|
|
||||||
if (activity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread thread = new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Statusgo.StopNodeRPCServer();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void stopNode() {
|
public void stopNode() {
|
||||||
|
|
||||||
|
@ -214,26 +214,6 @@ RCT_EXPORT_METHOD(moveToInternalStorage:(RCTResponseSenderBlock)onResultCallback
|
|||||||
onResultCallback(@[[NSNull null]]);
|
onResultCallback(@[[NSNull null]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
#pragma mark - StartNodeRPCServer method
|
|
||||||
//////////////////////////////////////////////////////////////////// createAccount
|
|
||||||
RCT_EXPORT_METHOD(startNodeRPCServer) {
|
|
||||||
#if DEBUG
|
|
||||||
NSLog(@"StartNodeRPCServer() method called");
|
|
||||||
#endif
|
|
||||||
StartNodeRPCServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
#pragma mark - StopNodeRPCServer method
|
|
||||||
//////////////////////////////////////////////////////////////////// createAccount
|
|
||||||
RCT_EXPORT_METHOD(stopNodeRPCServer) {
|
|
||||||
#if DEBUG
|
|
||||||
NSLog(@"StopNodeRPCServer() method called");
|
|
||||||
#endif
|
|
||||||
StopNodeRPCServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
#pragma mark - StopNode method
|
#pragma mark - StopNode method
|
||||||
//////////////////////////////////////////////////////////////////// StopNode
|
//////////////////////////////////////////////////////////////////// StopNode
|
||||||
|
@ -36,18 +36,6 @@
|
|||||||
(module-interface/-stop-node rns-module))
|
(module-interface/-stop-node rns-module))
|
||||||
|
|
||||||
|
|
||||||
(defn stop-rpc-server []
|
|
||||||
(module-interface/-stop-rpc-server rns-module))
|
|
||||||
|
|
||||||
|
|
||||||
(defn start-rpc-server []
|
|
||||||
(module-interface/-start-rpc-server rns-module))
|
|
||||||
|
|
||||||
|
|
||||||
(defn restart-rpc []
|
|
||||||
(module-interface/-restart-rpc rns-module))
|
|
||||||
|
|
||||||
|
|
||||||
(defn create-account [password callback]
|
(defn create-account [password callback]
|
||||||
(module-interface/-create-account rns-module password callback))
|
(module-interface/-create-account rns-module password callback))
|
||||||
|
|
||||||
|
@ -81,29 +81,6 @@
|
|||||||
(when status
|
(when status
|
||||||
(call-module #(.startNode status config))))
|
(call-module #(.startNode status config))))
|
||||||
|
|
||||||
(defn stop-rpc-server []
|
|
||||||
(when status
|
|
||||||
(call-module #(.stopNodeRPCServer status))))
|
|
||||||
|
|
||||||
(defn start-rpc-server []
|
|
||||||
(when status
|
|
||||||
(call-module #(.startNodeRPCServer status))))
|
|
||||||
|
|
||||||
(defonce restarting-rpc (atom false))
|
|
||||||
|
|
||||||
(defn restart-rpc []
|
|
||||||
(when-not @restarting-rpc
|
|
||||||
(reset! restarting-rpc true)
|
|
||||||
(log/debug :restart-rpc-on-post-error)
|
|
||||||
|
|
||||||
;; todo maybe it would be better to use something like
|
|
||||||
;; restart-rpc-server on status-go side
|
|
||||||
(stop-rpc-server)
|
|
||||||
(start-rpc-server)
|
|
||||||
|
|
||||||
(go (<! (timeout 3000))
|
|
||||||
(reset! restarting-rpc false))))
|
|
||||||
|
|
||||||
(defonce account-creation? (atom false))
|
(defonce account-creation? (atom false))
|
||||||
|
|
||||||
(defn create-account [password on-result]
|
(defn create-account [password on-result]
|
||||||
@ -244,12 +221,6 @@
|
|||||||
(start-node config))
|
(start-node config))
|
||||||
(-stop-node [this]
|
(-stop-node [this]
|
||||||
(stop-node))
|
(stop-node))
|
||||||
(-stop-rpc-server [this]
|
|
||||||
(stop-rpc-server))
|
|
||||||
(-start-rpc-server [this]
|
|
||||||
(start-rpc-server))
|
|
||||||
(-restart-rpc [this]
|
|
||||||
(restart-rpc))
|
|
||||||
(-create-account [this password callback]
|
(-create-account [this password callback]
|
||||||
(create-account password callback))
|
(create-account password callback))
|
||||||
(-recover-account [this passphrase password callback]
|
(-recover-account [this passphrase password callback]
|
||||||
|
@ -16,9 +16,6 @@
|
|||||||
(re-frame/dispatch [:signal-event "{\"type\":\"node.started\",\"event\":{}}"])
|
(re-frame/dispatch [:signal-event "{\"type\":\"node.started\",\"event\":{}}"])
|
||||||
(re-frame/dispatch [:signal-event "{\"type\":\"node.ready\",\"event\":{}}"]))
|
(re-frame/dispatch [:signal-event "{\"type\":\"node.ready\",\"event\":{}}"]))
|
||||||
(-stop-node [this])
|
(-stop-node [this])
|
||||||
(-stop-rpc-server [this])
|
|
||||||
(-start-rpc-server [this])
|
|
||||||
(-restart-rpc [this])
|
|
||||||
(-create-account [this password callback]
|
(-create-account [this password callback]
|
||||||
(let [address (str "c9f5c0e2bea0aabb6b0b618e9f45ab0958" (gstring/format "%06d" (rand-int 100000)))]
|
(let [address (str "c9f5c0e2bea0aabb6b0b618e9f45ab0958" (gstring/format "%06d" (rand-int 100000)))]
|
||||||
(callback (str "{\"address\":\"" address "\",\"pubkey\":\"0x046a313ba760e8853356b42a8732db1e2c339602977a3ac3d57ec2056449439b2c9f28e2e0dd243ac319f5da198b4a96f980d0ab6d4c7220ca7c5e1af2bd1ee8c7\",\"mnemonic\":\"robust rib ramp adult cannon amateur refuse burden review feel scout sell\",\"error\":\"\"}"))))
|
(callback (str "{\"address\":\"" address "\",\"pubkey\":\"0x046a313ba760e8853356b42a8732db1e2c339602977a3ac3d57ec2056449439b2c9f28e2e0dd243ac319f5da198b4a96f980d0ab6d4c7220ca7c5e1af2bd1ee8c7\",\"mnemonic\":\"robust rib ramp adult cannon amateur refuse burden review feel scout sell\",\"error\":\"\"}"))))
|
||||||
|
@ -5,9 +5,6 @@
|
|||||||
(-move-to-internal-storage [this callback])
|
(-move-to-internal-storage [this callback])
|
||||||
(-start-node [this config])
|
(-start-node [this config])
|
||||||
(-stop-node [this])
|
(-stop-node [this])
|
||||||
(-stop-rpc-server [this])
|
|
||||||
(-start-rpc-server [this])
|
|
||||||
(-restart-rpc [this])
|
|
||||||
(-create-account [this password callback])
|
(-create-account [this password callback])
|
||||||
(-recover-account [this passphrase password callback])
|
(-recover-account [this passphrase password callback])
|
||||||
(-login [this address password callback])
|
(-login [this address password callback])
|
||||||
|
@ -397,7 +397,6 @@
|
|||||||
android-error? (re-find (re-pattern "Failed to connect") message)]
|
android-error? (re-find (re-pattern "Failed to connect") message)]
|
||||||
(when (or ios-error? android-error?)
|
(when (or ios-error? android-error?)
|
||||||
(when android-error? (status/init-jail))
|
(when android-error? (status/init-jail))
|
||||||
(status/restart-rpc)
|
|
||||||
(dispatch [:load-commands!]))))))
|
(dispatch [:load-commands!]))))))
|
||||||
|
|
||||||
(register-handler
|
(register-handler
|
||||||
|
@ -158,16 +158,6 @@
|
|||||||
(fn []
|
(fn []
|
||||||
(status/module-initialized!)))
|
(status/module-initialized!)))
|
||||||
|
|
||||||
(reg-fx
|
|
||||||
::stop-rpc-server
|
|
||||||
(fn []
|
|
||||||
(status/stop-rpc-server)))
|
|
||||||
|
|
||||||
(reg-fx
|
|
||||||
::start-rpc-server
|
|
||||||
(fn []
|
|
||||||
(status/start-rpc-server)))
|
|
||||||
|
|
||||||
(reg-fx
|
(reg-fx
|
||||||
::request-permissions-fx
|
::request-permissions-fx
|
||||||
(fn [[permissions then else]]
|
(fn [[permissions then else]]
|
||||||
@ -348,10 +338,9 @@
|
|||||||
(register-handler-fx
|
(register-handler-fx
|
||||||
:app-state-change
|
:app-state-change
|
||||||
(fn [_ [_ state]]
|
(fn [_ [_ state]]
|
||||||
(case state
|
;; TODO(rasom): let's not remove this handler, it will be used for
|
||||||
"background" {::stop-rpc-server nil}
|
;; pausing node on entering background on android
|
||||||
"active" {::start-rpc-server nil}
|
))
|
||||||
nil)))
|
|
||||||
|
|
||||||
(register-handler-fx
|
(register-handler-fx
|
||||||
:request-permissions
|
:request-permissions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user