From ca960e8f075951f4facca9bddb0a41356371e650 Mon Sep 17 00:00:00 2001 From: mbaxter Date: Thu, 2 May 2019 13:20:52 -0400 Subject: [PATCH] Add explanatory comment about default port (#1392) --- .../pantheon/ethereum/p2p/network/netty/DeFramer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/netty/DeFramer.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/netty/DeFramer.java index 088bbab447..a505268de2 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/netty/DeFramer.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/netty/DeFramer.java @@ -171,7 +171,10 @@ private Peer createPeer(final PeerInfo peerInfo, final ChannelHandlerContext ctx final InetSocketAddress remoteAddress = ((InetSocketAddress) ctx.channel().remoteAddress()); int port = peerInfo.getPort(); if (port == 0) { - // Most peers advertise a port of "0", just set a default best guess in this case + // Most peers advertise a port of "0", just set a default best guess in this case. + // We can't simply use the remote address port because peers initiating inbound connections + // are free to choose any port they want for their side of the connection. The remote port + // does not actually correspond to the peer's listening port. port = EnodeURL.DEFAULT_LISTENING_PORT; } return DefaultPeer.fromEnodeURL(