Merge branch 'develop' of github.com:Agorise/graphenej into develop

This commit is contained in:
Nelson R. Perez 2018-09-27 17:43:45 -05:00
commit b37bb9dce0

View file

@ -22,7 +22,7 @@ import okhttp3.WebSocketListener;
public class NodeLatencyVerifier {
private final String TAG = this.getClass().getName();
public static final int DEFAULT_LATENCY_VERIFICATION_PERIOD = 5 * 1000;
private static final int DEFAULT_LATENCY_VERIFICATION_PERIOD = 5 * 1000;
// Variable used to store the list of nodes that should be verified
private List<FullNode> mNodeList;
@ -88,7 +88,7 @@ public class NodeLatencyVerifier {
long before = System.currentTimeMillis();
timestamps.put(fullNode, before);
// We want to reuse the same OkHttoClient instance if possible
// We want to reuse the same OkHttpClient instance if possible
if(client == null) client = new OkHttpClient();
// Same thing with the Request instance, we want to reuse them. But since
@ -143,9 +143,18 @@ public class NodeLatencyVerifier {
HttpUrl url = webSocket.request().url();
if(nodeURLMap.containsKey(url)){
FullNode fullNode = nodeURLMap.get(url);
long after = System.currentTimeMillis();
long before = timestamps.get(fullNode);
long delay = after - before;
long delay;
if(response == null) {
// There is no internet connection, or the node is unreachable. We are just
// putting an artificial delay.
delay = Long.MAX_VALUE;
} else {
long after = System.currentTimeMillis();
long before = timestamps.get(fullNode);
delay = after - before;
}
fullNode.addLatencyValue(delay);
subject.onNext(fullNode);
}else{