Activate new handler and fire read
This commit is contained in:
parent
1e3b496e8e
commit
f877d09f5a
|
@ -72,7 +72,7 @@ public class EthHandler extends SimpleChannelInboundHandler<Message> {
|
|||
this();
|
||||
this.peerListener = peerListener;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void channelRead0(final ChannelHandlerContext ctx, Message msg) throws InterruptedException {
|
||||
logger.trace("Read channel for {}", ctx.channel().remoteAddress());
|
||||
|
@ -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 {
|
||||
|
|
|
@ -84,10 +84,11 @@ public class P2pHandler extends SimpleChannelInboundHandler<Message> {
|
|||
processPeers((PeersMessage)msg);
|
||||
break;
|
||||
default:
|
||||
ctx.fireChannelRead(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
logger.error(cause.getCause().toString());
|
||||
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue