From 4a5ae622d1d590a3024fda11dcdf56480dbba1ec Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 12 Dec 2014 15:35:43 -0800 Subject: [PATCH] make use of getBlockByTx caching. --- lib/bitcoind.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/bitcoind.js b/lib/bitcoind.js index 34b6dada..7f497722 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -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); }); }