diff --git a/lib/net/pool.js b/lib/net/pool.js index d918d5a1..e0c6113d 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -352,9 +352,10 @@ Pool.prototype._disconnect = co(function* disconnect() { item.resolve(); } - this.peers.destroy(); + // prevent peer list from trying to refill + this.disconnecting = true; - this.nonces = new NonceList(); + this.peers.destroy(); this.requestMap.reset(); @@ -376,6 +377,7 @@ Pool.prototype._disconnect = co(function* disconnect() { yield this.unlisten(); + this.disconnecting = false; this.syncing = false; this.connected = false; }); @@ -1154,7 +1156,8 @@ Pool.prototype.handleClose = co(function* handleClose(peer, connected) { if (!outbound) return; - this.refill(); + if(!this.disconnecting) + this.refill(); }); /** @@ -3722,22 +3725,10 @@ PeerList.prototype.has = function has(hostname) { PeerList.prototype.destroy = function destroy() { var peer, next; - this.map = {}; - this.load = null; - this.inbound = 0; - this.outbound = 0; - for (peer = this.list.head; peer; peer = next) { next = peer.next; - - // stop processing peer events - peer.onPacket = null; - peer.removeAllListeners() - peer.destroy(); } - - this.list = new List(); }; /**