no db caching for now.
This commit is contained in:
parent
40da6fe0ae
commit
c4f204dfa8
@ -388,10 +388,12 @@ Bitcoin.prototype.getTx = function(txid, blockhash, callback) {
|
|||||||
blockhash = options.blockhash || options.block;
|
blockhash = options.blockhash || options.block;
|
||||||
traverse = options.traverse !== false;
|
traverse = options.traverse !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof blockhash === 'function') {
|
if (typeof blockhash === 'function') {
|
||||||
callback = blockhash;
|
callback = blockhash;
|
||||||
blockhash = '';
|
blockhash = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof blockhash !== 'string') {
|
if (typeof blockhash !== 'string') {
|
||||||
if (blockhash) {
|
if (blockhash) {
|
||||||
blockhash = blockhash.hash
|
blockhash = blockhash.hash
|
||||||
@ -402,6 +404,12 @@ Bitcoin.prototype.getTx = function(txid, blockhash, callback) {
|
|||||||
blockhash = '';
|
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') {
|
if (blockhash && typeof blockhash === 'string') {
|
||||||
return bitcoindjs.getTransaction(txid, blockhash, traverse, function(err, tx) {
|
return bitcoindjs.getTransaction(txid, blockhash, traverse, function(err, tx) {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
@ -412,6 +420,7 @@ Bitcoin.prototype.getTx = function(txid, blockhash, callback) {
|
|||||||
return callback(null, bitcoin.tx(tx));
|
return callback(null, bitcoin.tx(tx));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitcoin.db.get('tx-block/' + txid, function(err, block) {
|
return bitcoin.db.get('tx-block/' + txid, function(err, block) {
|
||||||
// Will traverse blockchain if no block - slow:
|
// Will traverse blockchain if no block - slow:
|
||||||
return bitcoinjs.getTransaction(txid, block ? block.hash : '', traverse, function(err, tx) {
|
return bitcoinjs.getTransaction(txid, block ? block.hash : '', traverse, function(err, tx) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user