From 7c6e5cf7b1a913fc4e33b67d282b4797b2c93b53 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Thu, 7 Apr 2016 10:14:43 -0400 Subject: [PATCH] bitcoind: only cache transaction with height if confirmations >= 6 --- lib/services/bitcoind.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index a0298cd6..8a1e9edb 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -42,6 +42,7 @@ function Bitcoin(options) { // caches valid indefinitely this.transactionCache = LRU(100000); this.transactionInfoCache = LRU(100000); + this.transactionInfoCacheConfirmations = 6; this.blockCache = LRU(144); this.blockHeaderCache = LRU(288); this.zmqKnownTransactions = LRU(50); @@ -1043,7 +1044,10 @@ Bitcoin.prototype.getTransactionWithBlockInfo = function(txid, queryMempool, cal tx.__blockHash = response.result.blockhash; tx.__height = response.result.height; tx.__timestamp = response.result.time; - self.transactionInfoCache.set(txid, tx); + var confirmations = self._getConfirmationsDetail(tx); + if (confirmations >= self.transactionInfoCacheConfirmations) { + self.transactionInfoCache.set(txid, tx); + } callback(null, tx); }); }