Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Ensure devp2p ports are written to ports file correctly #1020

Merged
merged 9 commits into from
Mar 4, 2019

Conversation

ajsutton
Copy link
Contributor

@ajsutton ajsutton commented Mar 1, 2019

PR description

Start P2P network synchronously so the ports are guaranteed to be known before we write the ports file.
Include the P2P TCP port in ports file even when peer discovery is disabled.
Load information from the advertised peer rather than the discovery listening socket so we get the right IP instead of 0.0.0.0.
Fix admin_nodeInfo to include the ?discport param in the enode URI when the discovery port differs from the P2P port and not fail with internal server error when p2p is enabled but discovery is disabled.

…wn before we write the ports file

Include the P2P TCP port in ports file even when peer discovery is disabled.
Load information from the advertised peer rather than the discovery listening socket.
Fix admin_nodeInfo to include the ?discport param in the enode URI when the discovery port differs from the P2P port.
@@ -89,7 +84,7 @@ public void start() {
if (started.compareAndSet(false, true)) {
LOG.info("Starting Network.");
setupHandlers();
networkExecutor.submit(network);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure why this ever had its own dedicated executor - starting the network is actually very quick as it basically just opens a port and returns.

final PeerInfo peerInfo = peerNetwork.getLocalPeerInfo();
final BytesValue nodeId = peerInfo.getNodeId();
final Peer advertisedPeer = peerNetwork.getAdvertisedPeer();
if (advertisedPeer != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update getAdvertisedPeer to return an Optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Good idea.

@ajsutton ajsutton merged commit 0925764 into PegaSysEng:master Mar 4, 2019
@ajsutton ajsutton deleted the fix-ports-file branch March 4, 2019 21:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants