From f6758c0e6fed846cf94d31ddf57ce5e7defc833b Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 8 Dec 2014 14:16:19 -0800 Subject: [PATCH] cache block by tx. --- lib/bitcoind.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/bitcoind.js b/lib/bitcoind.js index 02f21d8e..a2eb71f1 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -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)); }); };