Separate the metadata gets into additional promises since technically they are async

This commit is contained in:
Jordan Prince 2021-08-10 19:57:03 -05:00
parent 9170223fb0
commit e7abac452f
1 changed files with 4 additions and 1 deletions

View File

@ -59,6 +59,8 @@ export const loadAccounts = async (connection: Connection, all: boolean) => {
} }
}; };
const additionalPromises: Promise<void>[] = [];
const promises = [ const promises = [
connection.getProgramAccounts(VAULT_ID).then(forEach(processVaultData)), connection.getProgramAccounts(VAULT_ID).then(forEach(processVaultData)),
connection.getProgramAccounts(AUCTION_ID).then(forEach(processAuctions)), connection.getProgramAccounts(AUCTION_ID).then(forEach(processAuctions)),
@ -83,7 +85,7 @@ export const loadAccounts = async (connection: Connection, all: boolean) => {
for (let i = 0; i < MAX_CREATOR_LIMIT; i++) { for (let i = 0; i < MAX_CREATOR_LIMIT; i++) {
for (let j = 0; j < whitelistedCreators.length; j++) { for (let j = 0; j < whitelistedCreators.length; j++) {
promises.push( additionalPromises.push(
connection connection
.getProgramAccounts(METADATA_PROGRAM_ID, { .getProgramAccounts(METADATA_PROGRAM_ID, {
filters: [ filters: [
@ -115,6 +117,7 @@ export const loadAccounts = async (connection: Connection, all: boolean) => {
}), }),
]; ];
await Promise.all(promises); await Promise.all(promises);
await Promise.all(additionalPromises);
await postProcessMetadata(tempCache, all); await postProcessMetadata(tempCache, all);
console.log('Metadata size', tempCache.metadata.length); console.log('Metadata size', tempCache.metadata.length);