Added 'listenAddr' to p2p options.

This commit is contained in:
Chris Kleeschulte 2017-08-28 15:14:18 -04:00
parent 678b694a58
commit 4ebb7ac569
No known key found for this signature in database
GPG Key ID: 33195D27EF6BDB7F

View File

@ -167,15 +167,21 @@ P2P.prototype._broadcast = function(subscribers, name, entity) {
};
P2P.prototype._connect = function() {
var self = this;
log.info('Connecting to p2p network.');
self._pool.connect();
var retryInterval = setInterval(function() {
log.info('Retrying connection to p2p network.');
self._pool.connect();
}, 5000);
self._pool.once('peerready', function() {
clearInterval(retryInterval);
});
};
P2P.prototype._getBestHeight = function() {
@ -230,6 +236,7 @@ P2P.prototype._initPool = function() {
opts.addrs = this._configPeers;
}
opts.dnsSeed = false;
opts.listenAddr = false;
opts.maxPeers = this._maxPeers;
opts.network = this.node.network;
this._pool = new p2p.Pool(opts);
@ -249,12 +256,14 @@ P2P.prototype._onPeerBlock = function(peer, message) {
P2P.prototype._onPeerDisconnect = function(peer, addr) {
if (!this.node.stopping) {
log.info('Attempting to reconnect to the p2p network after disconnect signal.');
this._connect();
return;
}
this._removePeer(peer);
log.info('Disconnected from peer: ' + addr.ip.v4);
};
P2P.prototype._onPeerHeaders = function(peer, message) {