diff --git a/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java b/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java index 78e186c8..f6ea2e5a 100644 --- a/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java +++ b/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java @@ -51,10 +51,10 @@ public class WorldManager { this.blockchain = new BlockchainImpl(repository); // Initialize PeerData - List peerDataList = parsePeerDiscoveryIpList(CONFIG.peerDiscoveryIPList()); - peers.addAll(peerDataList); + Set peerDataList = parsePeerDiscoveryIpList(CONFIG.peerDiscoveryIPList()); +// peers.addAll(peerDataList); - peerDiscovery = new PeerDiscovery(peers); + peerDiscovery = new PeerDiscovery(peerDataList); } // used for testing @@ -89,13 +89,11 @@ public class WorldManager { synchronized (peers) { for (final Peer peer : newPeers) { - if (peerDiscovery.isStarted() && !peers.contains(peer)) { + if (peerDiscovery.isStarted() && !peers.contains(peer)) peerDiscovery.addNewPeerData(peer); - } peers.add(peer); } } - } public void startPeerDiscovery() { @@ -116,10 +114,10 @@ public class WorldManager { return listener; } - public List parsePeerDiscoveryIpList(final String peerDiscoveryIpList) { + public Set parsePeerDiscoveryIpList(final String peerDiscoveryIpList) { final List ipList = Arrays.asList(peerDiscoveryIpList.split(",")); - final List peers = new ArrayList<>(); + final Set peers = new HashSet<>(); for (String ip : ipList){ String[] addr = ip.trim().split(":"); diff --git a/ethereumj-core/src/main/java/org/ethereum/net/message/HelloMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/message/HelloMessage.java index 8c733e96..3493dc64 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/message/HelloMessage.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/message/HelloMessage.java @@ -143,8 +143,8 @@ public class HelloMessage extends Message { " p2pVersion=" + this.p2pVersion + " clientId=" + this.clientId + " capabilities=[" + Joiner.on(" ").join(this.capabilities) + "]" + - " peerPort=" + this.listenPort + " " + - " peerId=" + Hex.toHexString(this.peerId) + " " + + " peerPort=" + this.listenPort + + " peerId=" + Hex.toHexString(this.peerId) + "]"; } } \ No newline at end of file diff --git a/ethereumj-core/src/main/java/org/ethereum/net/message/PeersMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/message/PeersMessage.java index 804f2d00..47bc4944 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/message/PeersMessage.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/message/PeersMessage.java @@ -97,7 +97,7 @@ public class PeersMessage extends Message { StringBuffer sb = new StringBuffer(); for (Peer peerData : peers) { - sb.append("\n [").append(peerData).append("]"); + sb.append("\n ").append(peerData); } return "[command=" + this.getCommand().name() + sb.toString() + "]"; } diff --git a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerProtocolHandler.java b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerProtocolHandler.java index c29af173..adfc3745 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerProtocolHandler.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerProtocolHandler.java @@ -104,7 +104,6 @@ public class PeerProtocolHandler extends ChannelInboundHandlerAdapter { handshake = helloMessage; if (listener != null) listener.onRecvMessage(helloMessage); - sendGetPeers(); break; case STATUS: StatusMessage statusMessage = new StatusMessage(payload);