Browse Source

remove txCache from Transactions

use-env-var-docker
kenshin-samourai 4 years ago
parent
commit
9fac3e984d
  1. 21
      lib/bitcoind-rpc/transactions.js

21
lib/bitcoind-rpc/transactions.js

@ -23,15 +23,6 @@ class Transactions {
*/
constructor() {
// Caches
this.txCache = LRU({
// Maximum number of transactions to store
max: 10000,
// Function used to compute length of item
length: (n, key) => 1,
// Maximum age for items in the cache. Items do not expire
maxAge: Infinity
})
this.prevCache = LRU({
// Maximum number of transactions to store
max: 100000,
@ -85,19 +76,9 @@ class Transactions {
* @returns {Promise}
*/
async getTransaction(txid, fees) {
const keyCache = `${txid}-${fees ? '1' : '0'}`
// Return transaction from cache when possible
if (this.txCache.has(keyCache))
return this.txCache.get(keyCache)
try {
const tx = await this.rpcClient.getrawtransaction(txid, true)
const ret = await this._prepareTxResult(tx)
// Store the result in cache
if (ret.block && ret.block.hash)
this.txCache.set(txid, ret)
return ret
return this._prepareTxResult(tx)
} catch(e) {
Logger.error(e, 'Bitcoind RPC : Transaction.getTransaction()')
return Promise.reject(errors.generic.GEN)

Loading…
Cancel
Save