diff --git a/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java b/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java index 0532b26c..c9125087 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java @@ -20,8 +20,7 @@ public class SystemProperties { private static Logger logger = LoggerFactory.getLogger(SystemProperties.class); private static int DEFAULT_TX_APPROVE_TIMEOUT = 10; - private static String DEFAULT_DISCOVERY_PEER = "54.201.28.117"; - private static int DEFAULT_DISCOVERY_PORT = 30303; + private static String DEFAULT_DISCOVERY_PEER_LIST = "54.201.28.117:30303"; private static String DEFAULT_ACTIVE_PEER_IP = "54.201.28.117"; private static int DEFAULT_ACTIVE_PORT = 30303; private static String DEFAULT_SAMPLES_DIR = "samples"; @@ -98,16 +97,11 @@ public class SystemProperties { return Integer.parseInt(prop.getProperty("transaction.approve.timeout")); } - public String peerDiscoveryIP() { - if(prop.isEmpty()) return DEFAULT_DISCOVERY_PEER; - return prop.getProperty("peer.discovery.ip"); + public String peerDiscoveryIPList() { + if(prop.isEmpty()) return DEFAULT_DISCOVERY_PEER_LIST; + return prop.getProperty("peer.discovery.ip.list"); } - public int peerDiscoveryPort() { - if(prop.isEmpty()) return DEFAULT_DISCOVERY_PORT; - return Integer.parseInt(prop.getProperty("peer.discovery.port")); - } - public boolean databaseReset() { if(prop.isEmpty()) return DEFAULT_DB_RESET; return Boolean.parseBoolean(prop.getProperty("database.reset")); diff --git a/ethereumj-core/src/main/java/org/ethereum/gui/PeersTableModel.java b/ethereumj-core/src/main/java/org/ethereum/gui/PeersTableModel.java index 0856c17a..6211aad0 100644 --- a/ethereumj-core/src/main/java/org/ethereum/gui/PeersTableModel.java +++ b/ethereumj-core/src/main/java/org/ethereum/gui/PeersTableModel.java @@ -29,7 +29,7 @@ public class PeersTableModel extends AbstractTableModel { public void run() { updateModel(); } - }, 0, 1000); + }, 0, 100); } public String getColumnName(int column) { diff --git a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscovery.java b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscovery.java index 26fbc962..b9a9af3b 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscovery.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscovery.java @@ -35,11 +35,11 @@ public class PeerDiscovery { threadFactory = Executors.defaultThreadFactory(); //creating the ThreadPoolExecutor - executorPool = new ThreadPoolExecutor(1, 1000, 10, TimeUnit.SECONDS, + executorPool = new ThreadPoolExecutor(CONFIG.peerDiscoveryWorkers(), 1000, 10, TimeUnit.SECONDS, new ArrayBlockingQueue(CONFIG.peerDiscoveryWorkers()), threadFactory, rejectionHandler); //start the monitoring thread - monitor = new PeerDiscoveryMonitorThread(executorPool, 3); + monitor = new PeerDiscoveryMonitorThread(executorPool, 0); Thread monitorThread = new Thread(monitor); monitorThread.start(); diff --git a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscoveryMonitorThread.java b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscoveryMonitorThread.java index 2369b3e1..5c948bca 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscoveryMonitorThread.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscoveryMonitorThread.java @@ -25,7 +25,7 @@ public class PeerDiscoveryMonitorThread implements Runnable { @Override public void run() { while(run) { - logger.info( + logger.trace( String.format("[monitor] [%d/%d] Active: %d, Completed: %d, Task: %d, isShutdown: %s, isTerminated: %s, peersDiscovered: %d ", this.executor.getPoolSize(), this.executor.getCorePoolSize(), diff --git a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerTaster.java b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerTaster.java index f8a53681..d5c40394 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerTaster.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerTaster.java @@ -26,6 +26,7 @@ public class PeerTaster { public void connect(String host, int port) { + logger.debug("connecting: {}:{}", host, port); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { @@ -48,6 +49,7 @@ public class PeerTaster { // Wait until the connection is closed. f.channel().closeFuture().sync(); + logger.debug("connection is closed"); } catch (InterruptedException ie) { logger.info("-- ClientPeer: catch (InterruptedException ie) --"); diff --git a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/WorkerThread.java b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/WorkerThread.java index 2b6a407f..7451536c 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/WorkerThread.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/WorkerThread.java @@ -17,6 +17,7 @@ public class WorkerThread implements Runnable { ThreadPoolExecutor poolExecutor; private PeerData peerData; + private PeerTaster peerTaster = new PeerTaster(); public WorkerThread(PeerData peerData, ThreadPoolExecutor poolExecutor) { this.poolExecutor = poolExecutor; @@ -36,8 +37,7 @@ public class WorkerThread implements Runnable { private void processCommand() { try { - PeerTaster peerTaster = new PeerTaster(); - peerTaster.connect(peerData.getInetAddress().getHostName(), peerData.getPort()); + peerTaster.connect(peerData.getInetAddress().getHostAddress(), peerData.getPort()); byte capabilities = peerTaster.getCapabilities(); peerData.setOnline(true); diff --git a/ethereumj-core/src/main/resources/system.properties b/ethereumj-core/src/main/resources/system.properties index 89a74fcd..b695c57a 100644 --- a/ethereumj-core/src/main/resources/system.properties +++ b/ethereumj-core/src/main/resources/system.properties @@ -2,21 +2,15 @@ # accept for incoming connections [true/false] server.acceptConnections = false -# one default access point to start -# discover the network e.g. ip: [54.201.28.117] port: [30303] -# Peer Server Zero: peer discovery -#peer.discovery.ip = 54.72.69.180 -#peer.discovery.port = 30303 - -# Peer Server One: peer discovery +# List of the peers to start +# the search of the online peers +# values: [ip:port, ip:port, ip:port ...] +peer.discovery.ip.list = 185.43.109.23:30303,\ + 213.100.248.181:30303, \ + 54.72.69.180:30303, \ + 54.201.28.117:30303, \ + 70.29.74.8:7 -# Asimov -peer.discovery.ip = 185.43.109.23 -peer.discovery.port = 30303 - -# RomanJ -#peer.discovery.ip = 54.211.14.10 -#peer.discovery.port = 30303 # active peer ip and port # that is the peer through @@ -40,6 +34,9 @@ peer.active.port = 30303 #peer.active.ip = 54.72.69.180 #peer.active.port = 30303 +#peer.active.ip = 185.43.109.23 +#peer.active.port = 30303 + #peer.active.ip = 151.64.223.120 #peer.active.port = 30304 @@ -60,7 +57,7 @@ peer.discovery.workers = 15 # connection timeout for trying to # connect to a peer [seconds] -peer.discovery.timeout = 1 +peer.discovery.timeout = 3 # the time we wait to the network # to approve the transaction, the @@ -108,7 +105,7 @@ dump.clean.on.restart = true # make changes to tracing options # starting from certain block # -1 don't make any tracing changes -trace.startblock = 1155 +trace.startblock = -1 # invoke vm program on # message received,