bitcoind: only cache transaction with height if confirmations >= 6

This commit is contained in:
Braydon Fuller 2016-04-07 10:14:43 -04:00
parent 18310268a5
commit 7c6e5cf7b1

View File

@ -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);
});
}