Skip to content

[enhancement] Compute minting setup parameters in parallel#191

Open
steveluscher wants to merge 1 commit intoexiled-apes:mainfrom
steveluscher:parallelize-mint-setup
Open

[enhancement] Compute minting setup parameters in parallel#191
steveluscher wants to merge 1 commit intoexiled-apes:mainfrom
steveluscher:parallelize-mint-setup

Conversation

@steveluscher
Copy link
Copy Markdown

@steveluscher steveluscher commented Dec 11, 2021

Description

When the user clicks the mint button, we do four small async operations to set up the transaction. Despite the fact that none of these transactions depend on one another, we've written them to be executed in series.

const foo = await getFoo();
const bar = await getBar();
const baz = await getBaz();
const bat = await getBat();

Instead, what we can do is to generate all of the promises at once, let the network IO start, and wait on the results as a group.

const [foo, bar, baz, bat] = await Promise.all([
  getFoo(),
  getBar(),
  getBaz(),
  getBat(),
]);

This isn't going to result in a huge speedup, since most of the async work here is CPU bound and not network bound, but it's a good habit to get into none the less.

Type of change

  • Enhancement

How Has This Been Tested?

I loaded up the site locally and minted several tokens on devnet.

@steveluscher steveluscher changed the title [enhancement] Speed up minting by parallelizing setup [enhancement] Compute minting setup parameters in parallel Dec 11, 2021
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

Successfully merging this pull request may close these issues.

1 participant