Merge pull request #9 from nicksavers/master
Use Genesis.getHash() again instead of static value
This commit is contained in:
commit
48089837d5
|
@ -9,6 +9,7 @@
|
|||
.project
|
||||
.classpath
|
||||
.settings
|
||||
bin
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
|
|
|
@ -3,23 +3,18 @@ package org.ethereum.manager;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.ethereum.core.Block;
|
||||
import org.ethereum.core.Genesis;
|
||||
import org.ethereum.core.Transaction;
|
||||
import org.ethereum.core.Wallet;
|
||||
import org.ethereum.crypto.HashUtil;
|
||||
import org.ethereum.geodb.IpGeoDB;
|
||||
import org.ethereum.net.client.ClientPeer;
|
||||
import org.ethereum.net.client.PeerData;
|
||||
import org.ethereum.net.message.StaticMessages;
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import com.maxmind.geoip.Location;
|
||||
|
||||
/**
|
||||
* www.ethereumJ.com
|
||||
* User: Roman Mandeleil
|
||||
|
@ -91,9 +86,8 @@ public class MainData {
|
|||
}
|
||||
|
||||
public byte[] getLatestBlockHash(){
|
||||
|
||||
if (blockChainDB.isEmpty())
|
||||
return StaticMessages.GENESIS_HASH;
|
||||
return (new Genesis()).getHash();
|
||||
else
|
||||
return blockChainDB.get(blockChainDB.size() - 1).getHash();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package org.ethereum.net.message;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
|
||||
import org.ethereum.gui.PeerListener;
|
||||
import org.ethereum.manager.MainData;
|
||||
import org.ethereum.net.client.EthereumFrameDecoder;
|
||||
import org.ethereum.net.client.EthereumPeerTasterHandler;
|
||||
import org.ethereum.net.client.PeerData;
|
||||
|
||||
/**
|
||||
* www.ethereumJ.com
|
||||
* User: Roman Mandeleil
|
||||
* Created on: 10/04/14 12:28
|
||||
*/
|
||||
public class PeerTaster {
|
||||
|
||||
PeerListener peerListener;
|
||||
Channel channel;
|
||||
|
||||
public PeerTaster() {
|
||||
}
|
||||
|
||||
public PeerTaster(PeerListener peerListener) {
|
||||
this.peerListener = peerListener;
|
||||
}
|
||||
|
||||
public void connect(String host, int port){
|
||||
|
||||
EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
|
||||
try {
|
||||
Bootstrap b = new Bootstrap();
|
||||
b.group(workerGroup);
|
||||
b.channel(NioSocketChannel.class);
|
||||
|
||||
final EthereumPeerTasterHandler handler = new EthereumPeerTasterHandler();
|
||||
|
||||
b.handler(new ChannelInitializer<NioSocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(NioSocketChannel ch) throws Exception {
|
||||
|
||||
ch.pipeline().addLast("readTimeoutHandler", new ReadTimeoutHandler(15));
|
||||
ch.pipeline().addLast(new EthereumFrameDecoder());
|
||||
ch.pipeline().addLast(handler);
|
||||
}
|
||||
});
|
||||
|
||||
// Start the client.
|
||||
b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000);
|
||||
ChannelFuture f = b.connect(host, port).sync(); // (5)
|
||||
|
||||
// Wait until the connection is closed.
|
||||
f.channel().closeFuture().sync();
|
||||
|
||||
} catch (InterruptedException ie){
|
||||
System.out.println("-- ClientPeer: catch (InterruptedException ie) --");
|
||||
ie.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
workerGroup.shutdownGracefully().sync();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println("I am dead");
|
||||
}
|
||||
|
||||
public static void main(String args[]){
|
||||
|
||||
PeerTaster peerTaster = new PeerTaster();
|
||||
|
||||
try {peerTaster.connect("54.211.14.10", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("82.217.72.169", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("54.201.28.117", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("54.2.10.41", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("0.204.10.41", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("54.204.10.41", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("54.211.14.10", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("82.217.72.169", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("54.201.28.117", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("54.2.10.41", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("0.204.10.41", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
try {peerTaster.connect("54.204.10.41", 30303);} catch (Exception e) {e.printStackTrace();}
|
||||
|
||||
System.out.println("End of the roaad");
|
||||
|
||||
for (PeerData peer : MainData.instance.getPeers()){
|
||||
System.out.println(peer.getInetAddress().getHostAddress().toString());
|
||||
};
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ public class StaticMessages {
|
|||
|
||||
public static final byte[] DISCONNECT_00 = Hex.decode("2240089100000003C20100");
|
||||
public static final byte[] GET_CHAIN = Hex.decode("2240089100000027F82514A069A7356A245F9DC5B865475ADA5EE4E89B18F93C06503A9DB3B3630E88E9FB4E820100");
|
||||
public static final byte[] GENESIS_HASH = Hex.decode("f5232afe32aba6b366f8aa86a6939437c5e13d1fd71a0f51e77735d3456eb1a6");
|
||||
public static final byte[] GENESIS_HASH = Hex.decode("c305511e7cb9b33767e50f5e94ecd7b1c51359a04f45183860ec6808d80b0d3f");
|
||||
public static final byte[] MAGIC_PACKET = Hex.decode("22400891");
|
||||
|
||||
static {
|
||||
|
|
Loading…
Reference in New Issue