fix scriptPubKey cache
This commit is contained in:
parent
d1fb951aef
commit
fe7c499d09
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var imports = require('soop').imports();
|
||||
var _ = require('lodash');
|
||||
|
||||
|
||||
|
||||
@ -391,25 +392,28 @@ 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) {
|
||||
var txout = txouts[ii];
|
||||
_.each(txouts, function(txout) {
|
||||
|
||||
//everything already cached?
|
||||
if (txout.scriptPubKeyCached || txout.spentTxId) {
|
||||
continue;
|
||||
}
|
||||
if (txout.scriptPubKeyCached || txout.spentTxId)
|
||||
return;
|
||||
|
||||
// not hard confirmed ?
|
||||
if (!txout.isConfirmedCached && !txout.confirmedWillBeCached)
|
||||
return;
|
||||
|
||||
if (txout.scriptPubKey) {
|
||||
var infoToCache = [txout.value_sat, (txout.isConfirmedCached || txout.confirmedWillBeCached) ? 1 : 0, txout.scriptPubKey];
|
||||
var infoToCache = [txout.value_sat, 1, txout.scriptPubKey];
|
||||
dbScript.push({
|
||||
type: 'put',
|
||||
key: txout.key,
|
||||
value: infoToCache.join(':'),
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
db.batch(dbScript, cb);
|
||||
};
|
||||
|
||||
@ -573,7 +577,8 @@ TransactionDb.prototype.fillScriptPubKey = function(txouts, cb) {
|
||||
return a_c();
|
||||
});
|
||||
}, function() {
|
||||
if (!allCached)
|
||||
if (allCached)
|
||||
return cb();
|
||||
self.cacheScriptPubKey(txouts, cb);
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user