make use of getBlockByTx caching.

This commit is contained in:
Christopher Jeffrey 2014-12-12 15:35:43 -08:00
parent 00777ef855
commit 4a5ae622d1
1 changed files with 4 additions and 2 deletions

View File

@ -421,6 +421,8 @@ Bitcoin.prototype.getTx = function(txid, blockhash, callback) {
Bitcoin.prototype.getTransactionWithBlock = function(txid, blockhash, callback) {
if (bitcoin.stopping) return;
var self = this;
var slow = true;
if (typeof txid === 'object' && txid) {
@ -451,9 +453,9 @@ Bitcoin.prototype.getTransactionWithBlock = function(txid, blockhash, callback)
if (err) return callback(err);
if (slow && !tx.blockhash) {
return bitcoindjs.getBlockByTx(txid, function(err, block, tx_) {
return self.getBlockByTx(txid, function(err, block, tx_) {
if (err) return callback(err);
return callback(null, bitcoin.tx(tx), bitcoin.block(block));
return callback(null, tx, block);
});
}