mirror of https://github.com/m2049r/xmrwallet.git
don't show connection error if we havent tested yet (#700)
This commit is contained in:
parent
4e59be2dff
commit
08f815e830
|
@ -185,7 +185,6 @@ public class Dispatcher implements PeerRetriever.OnGetPeers {
|
|||
|
||||
public void seedPeers(Collection<NodeInfo> seedNodes) {
|
||||
for (NodeInfo node : seedNodes) {
|
||||
node.clear();
|
||||
if (node.isFavourite()) {
|
||||
rpcNodes.add(node);
|
||||
if (listener != null) listener.onGet(node);
|
||||
|
|
|
@ -563,7 +563,6 @@ public class NodeFragment extends Fragment
|
|||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
nodeInfo.clear();
|
||||
tvResult.setText(getString(R.string.node_testing, nodeInfo.getHostAddress()));
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ import okhttp3.ResponseBody;
|
|||
import timber.log.Timber;
|
||||
|
||||
public class NodeInfo extends Node {
|
||||
final static public int MIN_MAJOR_VERSION = 11;
|
||||
final static public int MIN_MAJOR_VERSION = 14;
|
||||
final static public String RPC_VERSION = "2.0";
|
||||
|
||||
private long height = 0;
|
||||
|
@ -54,6 +54,7 @@ public class NodeInfo extends Node {
|
|||
private int majorVersion = 0;
|
||||
private double responseTime = Double.MAX_VALUE;
|
||||
private int responseCode = 0;
|
||||
private boolean tested = false;
|
||||
|
||||
public void clear() {
|
||||
height = 0;
|
||||
|
@ -61,6 +62,11 @@ public class NodeInfo extends Node {
|
|||
responseTime = Double.MAX_VALUE;
|
||||
responseCode = 0;
|
||||
timestamp = 0;
|
||||
tested = false;
|
||||
}
|
||||
|
||||
public boolean isTested() {
|
||||
return tested;
|
||||
}
|
||||
|
||||
static public NodeInfo fromString(String nodeString) {
|
||||
|
@ -188,7 +194,7 @@ public class NodeInfo extends Node {
|
|||
}
|
||||
|
||||
private static final int HTTP_TIMEOUT = OkHttpHelper.HTTP_TIMEOUT;
|
||||
public static final double PING_GOOD = HTTP_TIMEOUT / 3; //ms
|
||||
public static final double PING_GOOD = HTTP_TIMEOUT / 3.0; //ms
|
||||
public static final double PING_MEDIUM = 2 * PING_GOOD; //ms
|
||||
public static final double PING_BAD = HTTP_TIMEOUT;
|
||||
|
||||
|
@ -251,8 +257,9 @@ public class NodeInfo extends Node {
|
|||
}
|
||||
}
|
||||
} catch (IOException | JSONException ex) {
|
||||
// failure
|
||||
Timber.d(ex);
|
||||
} finally {
|
||||
tested = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -147,11 +147,15 @@ public class NodeInfoAdapter extends RecyclerView.Adapter<NodeInfoAdapter.ViewHo
|
|||
nodeItem = nodeItems.get(position);
|
||||
tvName.setText(nodeItem.getName());
|
||||
ivPing.setImageResource(getPingIcon(nodeItem));
|
||||
if (nodeItem.isValid()) {
|
||||
Helper.showTimeDifference(tvIp, nodeItem.getTimestamp());
|
||||
if (nodeItem.isTested()) {
|
||||
if (nodeItem.isValid()) {
|
||||
Helper.showTimeDifference(tvIp, nodeItem.getTimestamp());
|
||||
} else {
|
||||
tvIp.setText(getResponseErrorText(context, nodeItem.getResponseCode()));
|
||||
tvIp.setTextColor(ColorHelper.getThemedColor(tvIp.getContext(), R.attr.colorError));
|
||||
}
|
||||
} else {
|
||||
tvIp.setText(getResponseErrorText(context, nodeItem.getResponseCode()));
|
||||
tvIp.setTextColor(ColorHelper.getThemedColor(tvIp.getContext(), R.attr.colorError));
|
||||
tvIp.setText(context.getResources().getString(R.string.node_testing, nodeItem.getHostAddress()));
|
||||
}
|
||||
itemView.setSelected(nodeItem.isSelected());
|
||||
itemView.setClickable(itemsClickable);
|
||||
|
|
|
@ -40,10 +40,7 @@ public class NodePinger {
|
|||
final ExecutorService exeService = Executors.newFixedThreadPool(NUM_THREADS);
|
||||
List<Callable<Boolean>> taskList = new ArrayList<>();
|
||||
for (NodeInfo node : nodes) {
|
||||
taskList.add(() -> {
|
||||
node.clear();
|
||||
return node.testRpcService(listener);
|
||||
});
|
||||
taskList.add(() -> node.testRpcService(listener));
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue