Skip to content

Commit 2f8f7ee

Browse files
authored
Merge pull request #152 from ckb-cell/develop
Merge develop to main branch (v2.1.1)
2 parents fcb4551 + 11d31ca commit 2f8f7ee

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "btc-assets-api",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"title": "Bitcoin/RGB++ Assets API",
55
"description": "",
66
"main": "index.js",

src/routes/bitcoin/address.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ const addressRoutes: FastifyPluginCallback<Record<never, never>, Server, ZodType
4343
const { min_satoshi, no_cache } = request.query;
4444

4545
let utxosCache = null;
46-
if (env.UTXO_SYNC_DATA_CACHE_ENABLE && no_cache !== 'true') {
47-
utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(address);
46+
if (env.UTXO_SYNC_DATA_CACHE_ENABLE) {
47+
if (no_cache !== 'true') {
48+
utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(address);
49+
}
4850
await fastify.utxoSyncer.enqueueSyncJob(address);
4951
}
5052
const utxos = utxosCache ? utxosCache : await fastify.bitcoin.getAddressTxsUtxo({ address });
@@ -103,8 +105,10 @@ const addressRoutes: FastifyPluginCallback<Record<never, never>, Server, ZodType
103105
const { only_confirmed, min_satoshi, no_cache } = request.query;
104106

105107
let utxosCache = null;
106-
if (env.UTXO_SYNC_DATA_CACHE_ENABLE && no_cache !== 'true') {
107-
utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(address);
108+
if (env.UTXO_SYNC_DATA_CACHE_ENABLE) {
109+
if (no_cache !== 'true') {
110+
utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(address);
111+
}
108112
await fastify.utxoSyncer.enqueueSyncJob(address);
109113
}
110114
let utxos = utxosCache ? utxosCache : await fastify.bitcoin.getAddressTxsUtxo({ address });

src/routes/rgbpp/address.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,19 @@ const addressRoutes: FastifyPluginCallback<Record<never, never>, Server, ZodType
6464
}
6565

6666
let utxosCache = null;
67-
if (env.UTXO_SYNC_DATA_CACHE_ENABLE && no_cache !== 'true') {
68-
utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(btc_address);
67+
if (env.UTXO_SYNC_DATA_CACHE_ENABLE) {
68+
if (no_cache !== 'true') {
69+
utxosCache = await fastify.utxoSyncer.getUTXOsFromCache(btc_address);
70+
}
6971
await fastify.utxoSyncer.enqueueSyncJob(btc_address);
7072
}
7173
const utxos = utxosCache ? utxosCache : await fastify.bitcoin.getAddressTxsUtxo({ address: btc_address });
7274

7375
let rgbppCache = null;
74-
if (env.RGBPP_COLLECT_DATA_CACHE_ENABLE && no_cache !== 'true') {
75-
rgbppCache = await fastify.rgbppCollector.getRgbppCellsFromCache(btc_address);
76+
if (env.RGBPP_COLLECT_DATA_CACHE_ENABLE) {
77+
if (no_cache !== 'true') {
78+
rgbppCache = await fastify.rgbppCollector.getRgbppCellsFromCache(btc_address);
79+
}
7680
await fastify.rgbppCollector.enqueueCollectJob(btc_address, utxos);
7781
}
7882

src/services/utxo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export default class UTXOSyncer extends BaseQueueWorker<IUTXOSyncRequest, IUTXOS
172172
}
173173

174174
const txs = await this.cradle.bitcoin.getAddressTxs({ address: btcAddress });
175-
const txsHash = sha256(Buffer.from(txs.map((tx) => tx.txid).join(','))).toString();
175+
const txsHash = sha256(Buffer.from(txs.map((tx) => tx.txid + JSON.stringify(tx.status)).join(','))).toString();
176176

177177
// check if the data is updated
178178
const cached = await this.dataCache.get(btcAddress);

0 commit comments

Comments
 (0)