From 101ecd3481a04235972b9f9394a92ceda3121743 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 14 Feb 2014 20:50:42 -0300 Subject: [PATCH] add concurrency limit --- lib/TransactionDb.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index 6c1efcdb..5eb7d7cc 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -21,7 +21,7 @@ function spec(b) { // TODO: use bitcore networks module var genesisTXID = '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b'; - var CONCURRENCY = 100; + var CONCURRENCY = 10; var MAX_OPEN_FILES = 500; /** @@ -318,7 +318,7 @@ function spec(b) { if (o.multipleSpendAttempts) { - async.each(o.multipleSpendAttempts, + async.eachLimit(o.multipleSpendAttempts, CONCURRENCY, function(oi, e_c) { self.isConfirmed(oi.spendTxId, function(err, is) { if (err) return; @@ -365,7 +365,7 @@ function spec(b) { }) .on('end', function() { - async.each(ret, function(o, e_c) { + async.eachLimit(ret, CONCURRENCY, function(o, e_c) { var k = SPEND_PREFIX + o.txid + '-' + o.index; db.createReadStream({ start: k, @@ -383,7 +383,7 @@ function spec(b) { }); }, function() { - async.each(ret, function(o, e_c) { + async.eachLimit(ret, CONCURRENCY, function(o, e_c) { self.fillConfirmations(o, e_c); }, function(err) { return cb(err, ret);