bip150/bip151: destroy on peer close.
This commit is contained in:
parent
db07d42803
commit
23f9e543be
@ -237,6 +237,13 @@ BIP150.prototype.findAuthorized = function findAuthorized(hash) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BIP150.prototype.destroy = function destroy() {
|
||||||
|
if (this.timeout != null) {
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
this.timeout = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
BIP150.prototype.complete = function complete(err) {
|
BIP150.prototype.complete = function complete(err) {
|
||||||
assert(!this.completed, 'Already completed.');
|
assert(!this.completed, 'Already completed.');
|
||||||
assert(this.callback, 'No completion callback.');
|
assert(this.callback, 'No completion callback.');
|
||||||
|
|||||||
@ -677,6 +677,17 @@ BIP151.prototype.wait = function wait(timeout, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy BIP151 state and streams.
|
||||||
|
*/
|
||||||
|
|
||||||
|
BIP151.prototype.destroy = function destroy() {
|
||||||
|
if (this.timeout != null) {
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
this.timeout = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feed ciphertext payload chunk
|
* Feed ciphertext payload chunk
|
||||||
* to the input stream. Potentially
|
* to the input stream. Potentially
|
||||||
|
|||||||
@ -698,8 +698,16 @@ Peer.prototype.destroy = function destroy() {
|
|||||||
|
|
||||||
this.destroyed = true;
|
this.destroyed = true;
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
|
|
||||||
this.socket.destroy();
|
this.socket.destroy();
|
||||||
this.socket = null;
|
this.socket = null;
|
||||||
|
|
||||||
|
if (this.bip151)
|
||||||
|
this.bip151.destroy();
|
||||||
|
|
||||||
|
if (this.bip150)
|
||||||
|
this.bip150.destroy();
|
||||||
|
|
||||||
this.emit('close');
|
this.emit('close');
|
||||||
|
|
||||||
if (this.ping.timer) {
|
if (this.ping.timer) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user