Activate new handler and fire read

This commit is contained in:
nicksavers 2014-10-04 21:58:48 +02:00
parent 1e3b496e8e
commit f877d09f5a
2 changed files with 5 additions and 4 deletions

View File

@ -137,7 +137,7 @@ public class EthHandler extends SimpleChannelInboundHandler<Message> {
*/
private void processStatus(StatusMessage msg, ChannelHandlerContext ctx) {
if (!Arrays.equals(msg.getGenesisHash(), Blockchain.GENESIS_HASH) || msg.getProtocolVersion() != 33)
ctx.pipeline().remove(this);
ctx.pipeline().remove(this); // Peer is not compatible for the 'eth' sub-protocol
else if (msg.getNetworkId() != 0)
msgQueue.sendMessage(new DisconnectMessage(ReasonCode.INCOMPATIBLE_NETWORK));
else {

View File

@ -84,6 +84,7 @@ public class P2pHandler extends SimpleChannelInboundHandler<Message> {
processPeers((PeersMessage)msg);
break;
default:
ctx.fireChannelRead(msg);
break;
}
}
@ -116,7 +117,7 @@ public class P2pHandler extends SimpleChannelInboundHandler<Message> {
msgQueue.sendMessage(new DisconnectMessage(ReasonCode.INCOMPATIBLE_PROTOCOL));
else {
if(msg.getCapabilities().contains("eth"))
ctx.pipeline().addLast(new EthHandler(peerListener));
ctx.pipeline().addLast(new EthHandler(peerListener)).fireChannelActive();
InetAddress address = ((InetSocketAddress) ctx.channel().remoteAddress()).getAddress();
int port = msg.getListenPort();