From 0e234c7c3ac575e0a81dcbac8a027b8ad9d44c75 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 30 Nov 2016 21:00:40 -0800 Subject: [PATCH] net: fix destroy check. --- lib/net/peer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/net/peer.js b/lib/net/peer.js index b0e0c338..e0834a13 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -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