net: fix destroy check.

This commit is contained in:
Christopher Jeffrey 2016-11-30 21:00:40 -08:00
parent f4f4f2b433
commit 0e234c7c3a
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1052,9 +1052,6 @@ Peer.prototype.getData = function getData(items) {
Peer.prototype._onPacket = co(function* onPacket(packet) {
var unlock;
if (this.destroyed)
throw new Error('Destroyed peer sent a packet.');
switch (packet.type) {
case packetTypes.VERSION:
case packetTypes.CMPCTBLOCK:
@ -1082,6 +1079,9 @@ Peer.prototype._onPacket = co(function* onPacket(packet) {
Peer.prototype.__onPacket = co(function* onPacket(packet) {
this.lastRecv = util.ms();
if (this.destroyed)
throw new Error('Destroyed peer sent a packet.');
if (this.bip151
&& !this.bip151.completed
&& packet.type !== packetTypes.ENCINIT