Skip to content

Commit

Permalink
fix(p2p): connect to peers with lastAddress only
Browse files Browse the repository at this point in the history
This fixes a bug whereby we would not connect to nodes that did not
have listening addresses advertised but *did* have a `lastAddress`
that we'd used to connect to them in the past and should use again.

Fixes #606.
  • Loading branch information
sangaman committed Oct 26, 2018
1 parent 1a038a2 commit da960d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/p2p/Pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ class Pool extends EventEmitter {
this.handshakeData = handshakeData;
this.handshakeData.addresses = this.addresses;

this.logger.info('Connecting to known / previously connected peers');
this.bindNodeList();

this.nodes.load().then(() => {
this.logger.info('Connecting to known / previously connected peers');
return this.connectNodes(this.nodes, false, true);
}).then(() => {
this.logger.info('Completed start-up connections to known peers.');
Expand Down Expand Up @@ -232,7 +232,7 @@ class Pool extends EventEmitter {
const isNotUs = node.nodePubKey !== this.handshakeData.nodePubKey;

// check that it has listening addresses,
const hasAddresses = node.addresses.length > 0;
const hasAddresses = node.lastAddress || node.addresses.length;

// ignore nodes that we already know if ignoreKnown is true
const isNotIgnored = this.nodes.has(node.nodePubKey) && !ignoreKnown;
Expand Down

0 comments on commit da960d6

Please sign in to comment.