Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce number of params in call to getMultipleAccountsInfo #50

Open
DamiToma opened this issue Oct 14, 2024 · 0 comments
Open

Reduce number of params in call to getMultipleAccountsInfo #50

DamiToma opened this issue Oct 14, 2024 · 0 comments

Comments

@DamiToma
Copy link

I noticed the extract function calls connection.getMultipleAccountsInfo(accountsToBeFetched) with duplicates. Sometimes the same PublicKey is found multiple times in the list of accounts to be fetched. Could this be reduced to avoid requesting same info multiple times?

const uniqueAccountsToBeFetched = Array.from(
  new Set(accountsToBeFetched.map((account) => account.toBase58()))
).map((account) => new PublicKey(account));

const accountInfos = await connection.getMultipleAccountsInfo(
  uniqueAccountsToBeFetched
);
uniqueAccountsToBeFetched.forEach((account, index) => {
  accountInfosMap.set(account.toBase58(), accountInfos[index]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant