diff --git a/lib/services/p2p/index.js b/lib/services/p2p/index.js index f0fd0160..65e41808 100644 --- a/lib/services/p2p/index.js +++ b/lib/services/p2p/index.js @@ -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) {