Update json server after restart.

This commit is contained in:
Adrian Tiberius 2015-10-22 12:53:12 +02:00
parent ed8a2b6f5f
commit 187a6b49c3
1 changed files with 16 additions and 4 deletions

View File

@ -42,6 +42,7 @@ public class EthereumRemoteService extends EthereumService {
static EnumMap<EventFlag, List<String>> listenersByType = new EnumMap<EventFlag, List<String>>(EventFlag.class); static EnumMap<EventFlag, List<String>> listenersByType = new EnumMap<EventFlag, List<String>>(EventFlag.class);
public boolean isEthereumStarted = false; public boolean isEthereumStarted = false;
private String currentJsonRpcServer = null;
public EthereumRemoteService() { public EthereumRemoteService() {
@ -227,6 +228,9 @@ public class EthereumRemoteService extends EthereumService {
List<String> privateKeys = data.getStringArrayList("privateKeys"); List<String> privateKeys = data.getStringArrayList("privateKeys");
ethereum.init(privateKeys); ethereum.init(privateKeys);
startJsonRpc(null); startJsonRpc(null);
if (currentJsonRpcServer != null) {
this.changeJsonRpc(null);
}
isEthereumStarted = true; isEthereumStarted = true;
} }
@ -367,12 +371,20 @@ public class EthereumRemoteService extends EthereumService {
*/ */
protected void changeJsonRpc(Message message) { protected void changeJsonRpc(Message message) {
Bundle data = message.getData(); String server = null;
String server = data.getString("rpc_server"); if (message == null) {
if (jsonRpcServer != null) { if (currentJsonRpcServer != null) {
server = currentJsonRpcServer;
}
} else {
Bundle data = message.getData();
server = data.getString("rpc_server");
currentJsonRpcServer = server;
}
if (jsonRpcServer != null && server != null) {
((org.ethereum.android.jsonrpc.light.JsonRpcServer)jsonRpcServer).addRemoteServer(server, true); ((org.ethereum.android.jsonrpc.light.JsonRpcServer)jsonRpcServer).addRemoteServer(server, true);
} else { } else {
System.out.println("jsonRpcServer is null on changeJsonRpc ??"); System.out.println("jsonRpcServer or server is null on changeJsonRpc");
} }
} }