Skip to content
This repository was archived by the owner on Nov 10, 2021. It is now read-only.

Commit 1afcee0

Browse files
- crash solution for threaded queries
1 parent c297de8 commit 1afcee0

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

conseilUtil.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,21 @@ const getArtisticUniverse = async (max_time) => {
276276
const objectQueries = queryChunks.map(c => makeObjectQuery(c))
277277

278278
let universe = []
279-
await Promise.all(objectQueries.map(async (q) => await conseiljs.TezosConseilClient.getTezosEntityData({ url: conseilServer, apiKey: conseilApiKey, network: 'mainnet' }, 'mainnet', 'big_map_contents', q)
280-
.then(result => result.map(row => {
281-
const objectId = row['value'].toString().replace(/^Pair ([0-9]{1,}) .*/, '$1')
282-
const objectUrl = row['value'].toString().replace(/.* 0x([0-9a-z]{1,}) \}$/, '$1')
283-
const ipfsHash = Buffer.from(objectUrl, 'hex').toString().slice(7);
284-
285-
universe.push({ objectId, ipfsHash, minter: artistMap[objectId], swaps: swapMap[objectId] !== undefined ? swapMap[objectId] : []})
286-
}))))
279+
await Promise.all(
280+
objectQueries.map(async (q) => {
281+
const r = []
282+
try {
283+
r = await conseiljs.TezosConseilClient.getTezosEntityData({ url: conseilServer, apiKey: conseilApiKey, network: 'mainnet' }, 'mainnet', 'big_map_contents', q)
284+
.then(result => result.map(row => {
285+
const objectId = row['value'].toString().replace(/^Pair ([0-9]{1,}) .*/, '$1')
286+
const objectUrl = row['value'].toString().replace(/.* 0x([0-9a-z]{1,}) \}$/, '$1')
287+
const ipfsHash = Buffer.from(objectUrl, 'hex').toString().slice(7);
288+
289+
universe.push({ objectId, ipfsHash, minter: artistMap[objectId], swaps: swapMap[objectId] !== undefined ? swapMap[objectId] : []})
290+
})) // NOTE: it's a work in progress, this will drop failed requests and return a smaller set than expected
291+
} finally {
292+
return r
293+
}}))
287294

288295
return universe
289296
}

0 commit comments

Comments
 (0)