use scriptPubKeyCached!

This commit is contained in:
Matias Alejo Garcia 2016-02-22 14:45:57 -03:00
parent fe4c7fac8d
commit d1fb951aef

View File

@ -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);
});
};