no db caching for now.

This commit is contained in:
Christopher Jeffrey 2014-12-08 13:19:22 -08:00
parent 40da6fe0ae
commit c4f204dfa8
1 changed files with 9 additions and 0 deletions

View File

@ -388,10 +388,12 @@ Bitcoin.prototype.getTx = function(txid, blockhash, callback) {
blockhash = options.blockhash || options.block;
traverse = options.traverse !== false;
}
if (typeof blockhash === 'function') {
callback = blockhash;
blockhash = '';
}
if (typeof blockhash !== 'string') {
if (blockhash) {
blockhash = blockhash.hash
@ -402,6 +404,12 @@ Bitcoin.prototype.getTx = function(txid, blockhash, callback) {
blockhash = '';
}
}
return bitcoindjs.getTransaction(txid, blockhash, traverse, function(err, tx) {
if (err) return callback(err);
return callback(null, bitcoin.tx(tx));
});
if (blockhash && typeof blockhash === 'string') {
return bitcoindjs.getTransaction(txid, blockhash, traverse, function(err, tx) {
if (err) return callback(err);
@ -412,6 +420,7 @@ Bitcoin.prototype.getTx = function(txid, blockhash, callback) {
return callback(null, bitcoin.tx(tx));
});
}
return bitcoin.db.get('tx-block/' + txid, function(err, block) {
// Will traverse blockchain if no block - slow:
return bitcoinjs.getTransaction(txid, block ? block.hash : '', traverse, function(err, tx) {