minor fixes
This commit is contained in:
parent
561c4f2f86
commit
5f413d0ffb
|
@ -142,8 +142,11 @@ public class EthereumImpl implements Ethereum {
|
|||
public PeerClient getDefaultPeer(){
|
||||
|
||||
PeerClient peer = WorldManager.getInstance().getActivePeer();
|
||||
if (peer == null)
|
||||
if (peer == null){
|
||||
|
||||
peer = new PeerClient();
|
||||
WorldManager.getInstance().setActivePeer(peer);
|
||||
}
|
||||
return peer;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
package org.ethereum.jsontestsuite;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class JSONReader {
|
||||
|
||||
public static String loadJSON(String filename) {
|
||||
// return getFromLocal(filename);
|
||||
String json = getFromUrl("https://raw.githubusercontent.com/ethereum/tests/develop/" + filename);
|
||||
return json == "" ? json = getFromLocal(filename) : json;
|
||||
}
|
||||
|
||||
public static String getFromLocal(String filename) {
|
||||
System.out.println("Loading local file: " + filename);
|
||||
try {
|
||||
URL vmtest = ClassLoader.getSystemResource("jsontestsuite/" + filename);
|
||||
File vmTestFile = new File(vmtest.toURI());
|
||||
return new String(Files.readAllBytes(vmTestFile.toPath()));
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getFromUrl(String urlToRead) {
|
||||
URL url;
|
||||
HttpURLConnection conn;
|
||||
BufferedReader rd;
|
||||
String line;
|
||||
String result = "";
|
||||
try {
|
||||
url = new URL(urlToRead);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setConnectTimeout(3000);
|
||||
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
while ((line = rd.readLine()) != null) {
|
||||
result += line;
|
||||
}
|
||||
rd.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
package org.ethereum.jsontestsuite;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class JSONReader {
|
||||
|
||||
public static String loadJSON(String filename) {
|
||||
// return getFromLocal(filename);
|
||||
String json = getFromUrl("https://raw.githubusercontent.com/ethereum/tests/develop/" + filename);
|
||||
return json == "" ? json = getFromLocal(filename) : json;
|
||||
}
|
||||
|
||||
public static String getFromLocal(String filename) {
|
||||
System.out.println("Loading local file: " + filename);
|
||||
try {
|
||||
URL vmtest = ClassLoader.getSystemResource("jsontestsuite/" + filename);
|
||||
File vmTestFile = new File(vmtest.toURI());
|
||||
return new String(Files.readAllBytes(vmTestFile.toPath()));
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getFromUrl(String urlToRead) {
|
||||
URL url;
|
||||
HttpURLConnection conn;
|
||||
BufferedReader rd;
|
||||
String line;
|
||||
String result = "";
|
||||
try {
|
||||
url = new URL(urlToRead);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setConnectTimeout(3000);
|
||||
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
while ((line = rd.readLine()) != null) {
|
||||
result += line;
|
||||
}
|
||||
rd.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,6 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* www.ethergit.com
|
||||
*
|
||||
* @author: Roman Mandeleil
|
||||
* Created on: 15/10/2014 12:34
|
||||
|
|
|
@ -76,12 +76,13 @@ public class ConnectionConsoleWindow extends JFrame implements PeerListener {
|
|||
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
PeerClient clientPeer = UIEthereumManager.ethereum.getDefaultPeer();
|
||||
clientPeer.setPeerListener(thisConsole);
|
||||
clientPeer.connect(SystemProperties.CONFIG.activePeerIP(),
|
||||
SystemProperties.CONFIG.activePeerPort());
|
||||
|
||||
UIEthereumManager.ethereum.connect(SystemProperties.CONFIG.activePeerIP(),
|
||||
SystemProperties.CONFIG.activePeerPort());
|
||||
}
|
||||
};
|
||||
|
||||
UIEthereumManager.ethereum.getDefaultPeer().setPeerListener(this);
|
||||
t.start();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue