Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

Commit 95f0586

Browse files
authored
Merge pull request #713 from vasilenkoalexey/route-consignment
Check shard size before write to storage
2 parents 65c57cc + e8d07f9 commit 95f0586

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/network/shard-server.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ ShardServer.prototype._handleRequestError = function(err) {
145145
/**
146146
* Receives the data stream and writes it to storage
147147
* @param {http.IncomingMessage} req
148-
* @param {http.ServerResponse} req
148+
* @param {http.ServerResponse} res
149149
*/
150150
ShardServer.prototype.routeConsignment = function(req, res) {
151151
const self = this;
@@ -187,9 +187,6 @@ ShardServer.prototype.routeConsignment = function(req, res) {
187187
req.on('data', function(chunk) {
188188
received += chunk.length;
189189

190-
hasher.update(chunk);
191-
item.shard.write(chunk);
192-
193190
if (received > shardsize) {
194191
report.end(ExchangeReport.FAILURE, 'FAILED_INTEGRITY');
195192
self._bridgeClient.createExchangeReport(report);
@@ -199,6 +196,9 @@ ShardServer.prototype.routeConsignment = function(req, res) {
199196
result: 'Shard exceeds the amount defined in the contract'
200197
});
201198
}
199+
200+
hasher.update(chunk);
201+
item.shard.write(chunk);
202202
});
203203

204204
req.on('end', function() {

0 commit comments

Comments
 (0)