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

Block processor could query notes and swaps in parallel instead of in sequence #282

Open
turbocrime opened this issue Jan 31, 2025 · 0 comments

Comments

@turbocrime
Copy link
Collaborator

turbocrime commented Jan 31, 2025

for (const nullifier of nullifiers) {
const readPromise = (async () => {
const record =
(await this.indexedDb.getSpendableNoteByNullifier(nullifier)) ??
(await this.indexedDb.getSwapByNullifier(nullifier));
return { nullifier, record };
})();
readOperations.push(readPromise);
}

This nullish coalescing operator will wait for getSpendableNoteByNullifier to complete before attempting getSwapByNullifier.

Potentially, these promises could be raced to completion, possibly leading to benefit if the nullifier represents a swap. An index by nullifier is present, so this may not be a significant benefit.

Difficulty: An absent item will return with 'undefined', preventing the simplest Promise.race technique.

@turbocrime turbocrime changed the title Optimization: Block processor could query notes and swaps in parallel instead of in sequence Block processor could query notes and swaps in parallel instead of in sequence Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant