pool: some cleanup.

This commit is contained in:
Christopher Jeffrey 2017-01-27 00:11:34 -08:00
parent a61679c4a9
commit 394df48408
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -101,6 +101,7 @@ function Pool(options) {
this.locker = new Lock(true); this.locker = new Lock(true);
this.connected = false; this.connected = false;
this.disconnecting = false;
this.syncing = false; this.syncing = false;
this.spvFilter = null; this.spvFilter = null;
this.txFilter = null; this.txFilter = null;
@ -344,6 +345,8 @@ Pool.prototype._disconnect = co(function* disconnect() {
if (!this.connected) if (!this.connected)
return; return;
this.disconnecting = true;
hashes = this.invMap.keys(); hashes = this.invMap.keys();
for (i = 0; i < hashes.length; i++) { for (i = 0; i < hashes.length; i++) {
@ -352,9 +355,6 @@ Pool.prototype._disconnect = co(function* disconnect() {
item.resolve(); item.resolve();
} }
// prevent peer list from trying to refill
this.disconnecting = true;
this.peers.destroy(); this.peers.destroy();
this.requestMap.reset(); this.requestMap.reset();
@ -1156,7 +1156,7 @@ Pool.prototype.handleClose = co(function* handleClose(peer, connected) {
if (!outbound) if (!outbound)
return; return;
if(this.disconnecting) if (this.disconnecting)
return; return;
this.refill(); this.refill();