Skip to content

Commit

Permalink
Merge pull request #152 from ckb-cell/develop
Browse files Browse the repository at this point in the history
Merge develop to main branch (v2.1.1)
  • Loading branch information
ahonn authored May 23, 2024
2 parents fcb4551 + 11d31ca commit 2f8f7ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 8 additions & 4 deletions src/routes/bitcoin/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ const addressRoutes: FastifyPluginCallback<Record<never, never>, 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 });
Expand Down Expand Up @@ -103,8 +105,10 @@ const addressRoutes: FastifyPluginCallback<Record<never, never>, 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 });
Expand Down
12 changes: 8 additions & 4 deletions src/routes/rgbpp/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@ const addressRoutes: FastifyPluginCallback<Record<never, never>, 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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/utxo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default class UTXOSyncer extends BaseQueueWorker<IUTXOSyncRequest, IUTXOS
}

const txs = await this.cradle.bitcoin.getAddressTxs({ address: btcAddress });
const txsHash = sha256(Buffer.from(txs.map((tx) => 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);
Expand Down

0 comments on commit 2f8f7ee

Please sign in to comment.