From d1fb951aefbb0f37dc50d7c68bb3b779e61dcd35 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 22 Feb 2016 14:45:57 -0300 Subject: [PATCH] use scriptPubKeyCached! --- lib/TransactionDb.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index c2f2d78..f7c1de9 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -391,7 +391,7 @@ TransactionDb.prototype.cacheConfirmations = function(txouts, cb) { TransactionDb.prototype.cacheScriptPubKey = function(txouts, cb) { - // console.log('[TransactionDb.js.381:cacheScriptPubKey:]'); //TODO + console.log('[TransactionDb.js.381:cacheScriptPubKey:]'); //TODO var self = this; var dbScript = []; for (var ii in txouts) { @@ -560,9 +560,11 @@ TransactionDb.prototype.getStandardizedTx = function(tx, time, isCoinBase) { TransactionDb.prototype.fillScriptPubKey = function(txouts, cb) { var self = this; + var allCached = true; // Complete utxo info async.eachLimit(txouts, CONCURRENCY, function(txout, a_c) { if (txout.scriptPubKeyCached) return a_c(); + allCached = false; self.fromIdInfoSimple(txout.txid, function(err, info) { if (!info || !info.vout) return a_c(err); @@ -571,7 +573,8 @@ TransactionDb.prototype.fillScriptPubKey = function(txouts, cb) { return a_c(); }); }, function() { - self.cacheScriptPubKey(txouts, cb); + if (!allCached) + self.cacheScriptPubKey(txouts, cb); }); };