diff --git a/etc/sample.conf b/etc/sample.conf index 339ecdc4..d56b4771 100644 --- a/etc/sample.conf +++ b/etc/sample.conf @@ -44,7 +44,7 @@ bip151: true listen: true max-peers: 8 max-leeches: 30 -bip150: true +bip150: false identity-key: 74b4147957813b62cc8987f2b711ddb31f8cb46dcbf71502033da66053c8780a auth-peers: ./authorized-peers known-peers: ./known-peers diff --git a/lib/net/peer.js b/lib/net/peer.js index 771619af..0e46d618 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -292,7 +292,7 @@ Peer.prototype._onConnect = function _onConnect() { assert(!this.bip151.completed); this.logger.info('Attempting BIP151 handshake (%s).', this.hostname); this.write(this.framer.encinit(this.bip151.toEncinit())); - return this.bip151.wait(5000, function(err) { + return this.bip151.wait(3000, function(err) { if (err) self._error(err, true); self._onBIP151(); @@ -320,10 +320,19 @@ Peer.prototype._onBIP151 = function _onBIP151() { if (this.bip150) { assert(!this.bip150.completed); + + if (!this.bip151.handshake) + return this._error('BIP151 handshake was not completed for BIP150.'); + this.logger.info('Attempting BIP150 handshake (%s).', this.hostname); - if (this.bip150.outbound && this.bip150.peerIdentity) + + if (this.bip150.outbound) { + if (!this.bip150.peerIdentity) + return this._error('No known identity for peer.'); this.write(this.framer.authChallenge(this.bip150.toChallenge())); - return this.bip150.wait(5000, function(err) { + } + + return this.bip150.wait(3000, function(err) { if (err) return self._error(err); self._onHandshake();