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