-
Notifications
You must be signed in to change notification settings - Fork 130
Conversation
When receiving an AddPeer, or when loading the static-nodes.json file, pantheon should not accept its own NodeID as a valid connection.
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.
LGTM.
*/ | ||
package tech.pegasys.pantheon.ethereum.p2p; | ||
|
||
public class PreventLocalNodeConnection extends RuntimeException { |
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.
This probably should be more about what went wrong rather than why we don't allow it. So ConnectingToLocalPeerException
maybe? Also good to end exception names with Exception
(though we break that convention in a few places).
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.
Done.
@@ -369,6 +370,11 @@ public boolean addMaintainConnectionPeer(final Peer peer) { | |||
if (!isPeerAllowed(peer)) { | |||
throw new PeerNotPermittedException(); | |||
} | |||
|
|||
if (peer.getId().equals(this.getLocalPeerInfo().getNodeId())) { |
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.
nit: the this looks unnecessary
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.
LGTM
When receiving an AddPeer, or when loading the static-nodes.json file, pantheon
should not accept its own NodeID as a valid connection.