cache block by tx.

This commit is contained in:
Christopher Jeffrey 2014-12-08 14:16:19 -08:00
parent da82924717
commit f6758c0e6f
1 changed files with 5 additions and 0 deletions

View File

@ -530,6 +530,11 @@ Bitcoin.prototype.getBlockByTxid =
Bitcoin.prototype.getBlockByTx = function(txid, callback) {
return bitcoindjs.getBlockByTx(txid, function(err, block) {
if (err) return callback(err);
bitcoin.db.get('block-tx/' + txid, function(err, blocks) {
blocks = blocks || [];
blocks.push({ hash: block.hash });
bitcoin.db.set('block-tx/' + txid, blocks, utils.NOOP);
});
return callback(null, bitcoin.block(block));
});
};