-
Notifications
You must be signed in to change notification settings - Fork 130
[PAN-2560] Cleanup PeerConnection interface #1282
[PAN-2560] Cleanup PeerConnection interface #1282
Conversation
public SocketAddress getLocalAddress() { | ||
return ctx.channel().localAddress(); | ||
public InetSocketAddress getLocalAddress() { | ||
return (InetSocketAddress) ctx.channel().localAddress(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this always an InetStocketAddress
in the manner we use netty? Are there other things it could be, that we might actually use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs on SocketAddress
:
This class represents a Socket Address with no protocol attachment. As an abstract class, it is meant to be subclassed with a specific, protocol dependent, implementation.
And InetSocketAddress
:
This class implements an IP Socket Address (IP address + port number)
I think the change makes sense.
We were casting it all over the place assuming it was an InetSocketAddress
anyway and I think its better to just be explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, InetSocketAddress
is actually the only subclass of SocketAddress
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think we could probably just get rid of these methods. I'll try to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would localize where the cast is in the unlikely case it's ever a problem. But if we can get rid of the methods entirely that is also less code, which is generally better.
PR description
Small cleanup to the PeerConnection interface:
InetSocketAddress
valuesgetEnode
method, removeisRemoteEnode
since this can be checked directly nowgetPeer
togetPeerInfo