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:
Roman Volosovskyi 2017-10-04 21:56:27 +02:00 committed by GitHub
parent cede095746
commit a7950af335
8 changed files with 3 additions and 118 deletions

View File

@ -320,42 +320,6 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
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
public void stopNode() {

View File

@ -214,26 +214,6 @@ RCT_EXPORT_METHOD(moveToInternalStorage:(RCTResponseSenderBlock)onResultCallback
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
//////////////////////////////////////////////////////////////////// StopNode

View File

@ -36,18 +36,6 @@
(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]
(module-interface/-create-account rns-module password callback))

View File

@ -81,29 +81,6 @@
(when status
(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))
(defn create-account [password on-result]
@ -244,12 +221,6 @@
(start-node config))
(-stop-node [this]
(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 password callback))
(-recover-account [this passphrase password callback]

View File

@ -16,9 +16,6 @@
(re-frame/dispatch [:signal-event "{\"type\":\"node.started\",\"event\":{}}"])
(re-frame/dispatch [:signal-event "{\"type\":\"node.ready\",\"event\":{}}"]))
(-stop-node [this])
(-stop-rpc-server [this])
(-start-rpc-server [this])
(-restart-rpc [this])
(-create-account [this password callback]
(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\":\"\"}"))))

View File

@ -5,9 +5,6 @@
(-move-to-internal-storage [this callback])
(-start-node [this config])
(-stop-node [this])
(-stop-rpc-server [this])
(-start-rpc-server [this])
(-restart-rpc [this])
(-create-account [this password callback])
(-recover-account [this passphrase password callback])
(-login [this address password callback])

View File

@ -397,7 +397,6 @@
android-error? (re-find (re-pattern "Failed to connect") message)]
(when (or ios-error? android-error?)
(when android-error? (status/init-jail))
(status/restart-rpc)
(dispatch [:load-commands!]))))))
(register-handler

View File

@ -158,16 +158,6 @@
(fn []
(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
::request-permissions-fx
(fn [[permissions then else]]
@ -348,10 +338,9 @@
(register-handler-fx
:app-state-change
(fn [_ [_ state]]
(case state
"background" {::stop-rpc-server nil}
"active" {::start-rpc-server nil}
nil)))
;; TODO(rasom): let's not remove this handler, it will be used for
;; pausing node on entering background on android
))
(register-handler-fx
:request-permissions