|
|
@ -53,9 +53,11 @@ class Transactions { |
|
|
|
* @returns {Promise} |
|
|
|
*/ |
|
|
|
async getTransaction(txid, fees) { |
|
|
|
const keyCache = `${txid}-${fees ? '1' : '0'}` |
|
|
|
|
|
|
|
// Return transaction from cache when possible
|
|
|
|
if (this.txCache.has(txid)) |
|
|
|
return this.txCache.get(txid) |
|
|
|
if (this.txCache.has(keyCache)) |
|
|
|
return this.txCache.get(keyCache) |
|
|
|
|
|
|
|
try { |
|
|
|
const tx = await this.rpcClient.getrawtransaction(txid, true) |
|
|
@ -107,7 +109,7 @@ class Transactions { |
|
|
|
|
|
|
|
// Store in cache
|
|
|
|
if (ret.block && ret.block.hash) |
|
|
|
this.txCache.set(txid, ret) |
|
|
|
this.txCache.set(keyCache, ret) |
|
|
|
|
|
|
|
return ret |
|
|
|
|
|
|
|