Comparing version 0.8.2 to 0.8.3
{ | ||
"name": "curvecp", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"description": "Pure javascript CurveCP library", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -30,5 +30,3 @@ var Chicago = require('./chicago.js') | ||
self.push(null) | ||
_.forEach(self._writeRequests, function (request) { | ||
this.callback(new Error('Underlying stream closed')) | ||
}, self) | ||
self._cleanup() | ||
self._stream.removeAllListeners() | ||
@@ -75,2 +73,11 @@ self.emit('close') | ||
MessageStream.prototype._cleanup = function () { | ||
this._sendBytes = new Buffer(0) | ||
_.forEach(this._writeRequests, function (request) { | ||
request.callback(new Error('Underlying stream does not respond anymore')) | ||
}, this) | ||
this._writeRequests = [] | ||
this._outgoing = [] | ||
} | ||
MessageStream.prototype._nextMessageId = function () { | ||
@@ -113,5 +120,8 @@ var result = this.__nextMessageId | ||
debug('_process') | ||
if (_.some(this._outgoing, function (block) { | ||
return block.transmisions > constants.MAX_RETRANSMISSIONS | ||
})) { | ||
var maxReached = _.some(this._outgoing, function (block) { | ||
return block.transmissions > constants.MAX_RETRANSMISSIONS | ||
}) | ||
if (maxReached) { | ||
debug('maximum retransmissions reached') | ||
this._cleanup() | ||
this.emit('error', new Error('Maximum retransmissions reached - remote host down')) | ||
@@ -133,2 +143,3 @@ } | ||
if (this._sendBytes.length > constants.MAXIMUM_UNPROCESSED_SEND_BYTES) { | ||
debug('Buffer is full') | ||
done(new Error('Buffer is full')) | ||
@@ -169,2 +180,3 @@ return | ||
block.transmission_time = this._chicago.get_clock() | ||
debug(block.transmissions) | ||
block.transmissions = block.transmissions + 1 | ||
@@ -290,2 +302,4 @@ block.id = this._nextMessageId() | ||
this.__streamReady = true | ||
} else { | ||
debug('error while sending CurveCP message') | ||
} | ||
@@ -292,0 +306,0 @@ } |
@@ -9,2 +9,3 @@ 'use strict' | ||
var crypto = require('crypto') | ||
var _ = require('lodash') | ||
nacl.util = require('tweetnacl-util') | ||
@@ -91,2 +92,5 @@ | ||
error: function (err) { | ||
if (!_.isError(err)) { | ||
err = new Error(err) | ||
} | ||
curveStream.emit('error', err) | ||
@@ -93,0 +97,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64029
1554