diff --git a/lib/net/peer.js b/lib/net/peer.js index c47572c8..557d2256 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -91,7 +91,6 @@ function Peer(options) { this.ts = 0; this.lastSend = 0; this.lastRecv = 0; - this.drainStart = 0; this.drainSize = 0; this.drainQueue = []; this.banScore = 0; @@ -152,15 +151,6 @@ util.inherits(Peer, EventEmitter); Peer.DRAIN_MAX = 10 << 20; -/** - * Timeout for peer to read from - * their end of the socket. - * @const {Number} - * @default - */ - -Peer.DRAIN_TIMEOUT = 10000; - /** * Interval to check for drainage * and required responses from peer. @@ -394,9 +384,6 @@ Peer.prototype.bind = function bind(socket) { }); this.socket.on('data', function(chunk) { - if (self.maybeStall()) - return; - self.lastRecv = util.ms(); self.feedParser(chunk); }); @@ -556,7 +543,6 @@ Peer.prototype.initStall = function initStall() { assert(!this.stallTimer); assert(!this.destroyed); this.stallTimer = setInterval(function() { - self.maybeStall(); self.maybeTimeout(); }, Peer.STALL_INTERVAL); return Promise.resolve(); @@ -1208,13 +1194,6 @@ Peer.prototype.handleDrain = function handleDrain() { */ Peer.prototype.needsDrain = function needsDrain(size) { - if (this.maybeStall()) { - this.error('Peer stalled (drain).'); - this.destroy(); - return; - } - - this.drainStart = util.ms(); this.drainSize += size; if (this.drainSize >= Peer.DRAIN_MAX) { @@ -1227,26 +1206,6 @@ Peer.prototype.needsDrain = function needsDrain(size) { } }; -/** - * Potentially timeout peer if it hasn't read. - * @private - * @returns {Boolean} - */ - -Peer.prototype.maybeStall = function maybeStall() { - if (this.drainSize === 0) - return false; - - if (util.ms() < this.drainStart + Peer.DRAIN_TIMEOUT) - return false; - - this.drainSize = 0; - this.error('Peer stalled (write).'); - this.destroy(); - - return true; -}; - /** * Potentially add response timeout. * @private