Skip to content

Commit

Permalink
Merge pull request #282 from blockfrost/refactor/addressesToTxIds
Browse files Browse the repository at this point in the history
refactor: simplify addressesToTxIds
  • Loading branch information
slowbackspace authored Dec 13, 2024
2 parents f2e7457 + 9cc2005 commit 12f16b5
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,26 +191,20 @@ export const addressesToTxIds = async (
data: Responses['address_transactions_content'];
}>[] = [];

for (const item of addresses) {
if (item.data === 'empty') {
for (const { address, data: status } of addresses) {
if (status === 'empty') {
continue;
}

const promise = limiter(() =>
// 1 page (100 txs) per address at a time should be more efficient default value
// compared to fetching 10 pages (1000 txs) per address
blockfrostAPI
.addressesTransactionsAll(item.address, { batchSize: 1 })
.then(data => ({
address: item.address,
data,
}))
.addressesTransactionsAll(address, { batchSize: 1 })
.then(data => ({ address, data }))
.catch(error => {
if (error instanceof BlockfrostServerError && error.status_code === 404) {
return {
address: item.address,
data: [],
};
return { address, data: [] };
} else {
throw error;
}
Expand Down

0 comments on commit 12f16b5

Please sign in to comment.