diff --git a/package.json b/package.json index d89db6b5..19079eac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "btc-assets-api", - "version": "2.2.0", + "version": "2.2.1", "title": "Bitcoin/RGB++ Assets API", "description": "", "main": "index.js", diff --git a/src/routes/bitcoin/address.ts b/src/routes/bitcoin/address.ts index b65b8b7a..12eea2df 100644 --- a/src/routes/bitcoin/address.ts +++ b/src/routes/bitcoin/address.ts @@ -43,8 +43,10 @@ const addressRoutes: FastifyPluginCallback, Server, ZodType const { min_satoshi, no_cache } = request.query; let utxosCache = null; - if (env.UTXO_SYNC_DATA_CACHE_ENABLE && no_cache !== 'true') { - utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(address); + if (env.UTXO_SYNC_DATA_CACHE_ENABLE) { + if (no_cache !== 'true') { + utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(address); + } await fastify.utxoSyncer.enqueueSyncJob(address); } const utxos = utxosCache ? utxosCache : await fastify.bitcoin.getAddressTxsUtxo({ address }); @@ -103,8 +105,10 @@ const addressRoutes: FastifyPluginCallback, Server, ZodType const { only_confirmed, min_satoshi, no_cache } = request.query; let utxosCache = null; - if (env.UTXO_SYNC_DATA_CACHE_ENABLE && no_cache !== 'true') { - utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(address); + if (env.UTXO_SYNC_DATA_CACHE_ENABLE) { + if (no_cache !== 'true') { + utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(address); + } await fastify.utxoSyncer.enqueueSyncJob(address); } let utxos = utxosCache ? utxosCache : await fastify.bitcoin.getAddressTxsUtxo({ address }); diff --git a/src/routes/rgbpp/address.ts b/src/routes/rgbpp/address.ts index 9601843a..e58f71a5 100644 --- a/src/routes/rgbpp/address.ts +++ b/src/routes/rgbpp/address.ts @@ -64,15 +64,19 @@ const addressRoutes: FastifyPluginCallback, Server, ZodType } let utxosCache = null; - if (env.UTXO_SYNC_DATA_CACHE_ENABLE && no_cache !== 'true') { - utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(btc_address); + if (env.UTXO_SYNC_DATA_CACHE_ENABLE) { + if (no_cache !== 'true') { + utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(btc_address); + } await fastify.utxoSyncer.enqueueSyncJob(btc_address); } const utxos = utxosCache ? utxosCache : await fastify.bitcoin.getAddressTxsUtxo({ address: btc_address }); let rgbppCache = null; - if (env.RGBPP_COLLECT_DATA_CACHE_ENABLE && no_cache !== 'true') { - rgbppCache = await fastify.rgbppCollector.getRgbppCellsFromCache(btc_address); + if (env.RGBPP_COLLECT_DATA_CACHE_ENABLE) { + if (no_cache !== 'true') { + rgbppCache = await fastify.rgbppCollector.getRgbppCellsFromCache(btc_address); + } await fastify.rgbppCollector.enqueueCollectJob(btc_address, utxos); } diff --git a/src/services/utxo.ts b/src/services/utxo.ts index 9402745b..ca080be9 100644 --- a/src/services/utxo.ts +++ b/src/services/utxo.ts @@ -172,7 +172,7 @@ export default class UTXOSyncer extends BaseQueueWorker tx.txid).join(','))).toString(); + const txsHash = sha256(Buffer.from(txs.map((tx) => tx.txid + JSON.stringify(tx.status)).join(','))).toString(); // check if the data is updated const cached = await this.dataCache.get(btcAddress);