From f2564513b0cbbed2b8897dfc67102ef02d9b8209 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Sun, 24 Apr 2016 23:03:07 +0200 Subject: [PATCH] fix(block-service): limit all async calls --- src/block-service.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/block-service.js b/src/block-service.js index c271454..f8e72ad 100644 --- a/src/block-service.js +++ b/src/block-service.js @@ -20,7 +20,7 @@ function BlockService (ipfsRepo, exchange) { return callback(new Error('expects an array of Blocks')) } - async.each(blocks, (block, next) => { + async.eachLimit(blocks, 100, (block, next) => { this.addBlock(block, next) }, callback) } @@ -54,7 +54,7 @@ function BlockService (ipfsRepo, exchange) { var results = {} - async.each(multihashes, (multihash, next) => { + async.eachLimit(multihashes, 100, (multihash, next) => { this.getBlock(multihash, extension, (err, block) => { results[multihash] = { err: err, @@ -90,7 +90,7 @@ function BlockService (ipfsRepo, exchange) { return callback(new Error('Invalid batch of multihashes')) } - async.each(multihashes, (multihash, next) => { + async.eachLimit(multihashes, 100, (multihash, next) => { this.deleteBlock(multihash, extension, next) }, (err) => { callback(err)