Merge branch 'develop' of github.com:Agorise/graphenej into develop
This commit is contained in:
commit
2a64a9ec22
1 changed files with 22 additions and 23 deletions
|
@ -169,8 +169,6 @@ public class NetworkService extends Service {
|
||||||
private String mLastCall;
|
private String mLastCall;
|
||||||
private long mCurrentId = 0;
|
private long mCurrentId = 0;
|
||||||
|
|
||||||
private boolean mAutoConnect;
|
|
||||||
|
|
||||||
// Requested APIs passed to this service
|
// Requested APIs passed to this service
|
||||||
private int mRequestedApis;
|
private int mRequestedApis;
|
||||||
|
|
||||||
|
@ -311,7 +309,7 @@ public class NetworkService extends Service {
|
||||||
mUsername = extras.getString(NetworkService.KEY_USERNAME, "");
|
mUsername = extras.getString(NetworkService.KEY_USERNAME, "");
|
||||||
mPassword = extras.getString(NetworkService.KEY_PASSWORD, "");
|
mPassword = extras.getString(NetworkService.KEY_PASSWORD, "");
|
||||||
mRequestedApis = extras.getInt(NetworkService.KEY_REQUESTED_APIS, 0);
|
mRequestedApis = extras.getInt(NetworkService.KEY_REQUESTED_APIS, 0);
|
||||||
mAutoConnect = extras.getBoolean(NetworkService.KEY_AUTO_CONNECT, true);
|
boolean mAutoConnect = extras.getBoolean(NetworkService.KEY_AUTO_CONNECT, true);
|
||||||
boolean verifyNodeLatency = extras.getBoolean(NetworkService.KEY_ENABLE_LATENCY_VERIFIER, false);
|
boolean verifyNodeLatency = extras.getBoolean(NetworkService.KEY_ENABLE_LATENCY_VERIFIER, false);
|
||||||
|
|
||||||
// If the user of the library desires, a custom list of node URLs can
|
// If the user of the library desires, a custom list of node URLs can
|
||||||
|
@ -329,15 +327,11 @@ public class NetworkService extends Service {
|
||||||
nodeProvider.addNode(new FullNode(nodeUrl));
|
nodeProvider.addNode(new FullNode(nodeUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We only connect automatically if the auto-connect flag is true AND
|
if (!mAutoConnect && !verifyNodeLatency) {
|
||||||
// we are not going to care about node latency ordering.
|
throw new IllegalArgumentException("NetworkService$bootstrapService: verifyNodeLatency cannot be false when autoConnect is false too.");
|
||||||
if(mAutoConnect && !verifyNodeLatency) {
|
}
|
||||||
connect();
|
|
||||||
}else{
|
if (verifyNodeLatency) {
|
||||||
// In case we care about node latency ordering, we must first obtain
|
|
||||||
// a first round of measurements in order to be sure to select the
|
|
||||||
// best node.
|
|
||||||
if(verifyNodeLatency){
|
|
||||||
double alpha = extras.getDouble(KEY_NODE_LATENCY_SMOOTHING_FACTOR, ExponentialMovingAverage.DEFAULT_ALPHA);
|
double alpha = extras.getDouble(KEY_NODE_LATENCY_SMOOTHING_FACTOR, ExponentialMovingAverage.DEFAULT_ALPHA);
|
||||||
ArrayList<FullNode> fullNodes = new ArrayList<>();
|
ArrayList<FullNode> fullNodes = new ArrayList<>();
|
||||||
for(String url : urls){
|
for(String url : urls){
|
||||||
|
@ -346,9 +340,14 @@ public class NetworkService extends Service {
|
||||||
nodeLatencyVerifier = new NodeLatencyVerifier(fullNodes);
|
nodeLatencyVerifier = new NodeLatencyVerifier(fullNodes);
|
||||||
fullNodePublishSubject = nodeLatencyVerifier.start();
|
fullNodePublishSubject = nodeLatencyVerifier.start();
|
||||||
fullNodePublishSubject.observeOn(AndroidSchedulers.mainThread()).subscribe(nodeLatencyObserver);
|
fullNodePublishSubject.observeOn(AndroidSchedulers.mainThread()).subscribe(nodeLatencyObserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mAutoConnect)
|
||||||
|
connect();
|
||||||
|
else
|
||||||
mHandler.postDelayed(mConnectAttempt, DEFAULT_INITIAL_DELAY);
|
mHandler.postDelayed(mConnectAttempt, DEFAULT_INITIAL_DELAY);
|
||||||
}
|
|
||||||
}
|
// TODO make sure (verifyNodeLatency==false && mAutoConnect==true) is a valid/useful combination, else simplify and use only one of those arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue