-
Notifications
You must be signed in to change notification settings - Fork 294
chore: parallellize keychain and queryPromise #6136
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
Conversation
e0befb2
to
7baae82
Compare
8ecb7ea
to
bbb3faa
Compare
c682e7c
to
2ba5ea3
Compare
87c70b9
to
c829563
Compare
4bd8ccb
to
037ee71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cd404c2
cd6d3e3
to
a8c3591
Compare
b3d5358
to
8728b12
Compare
74898a8
to
87f8de4
Compare
Ticket: CAAS-7
344b4c7
to
5367fbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the performance of the /sendcoins endpoint by parallellizing the keychain validation and transaction prebuild queries in the prebuildAndSignTransaction function.
- Parallelizes calls to getKeychainsAndValidatePassphrase and prebuildTransaction.
- Uses Promise.allSettled to concurrently process asynchronous operations and handle their outcomes.
Comments suppressed due to low confidence (1)
modules/sdk-core/src/bitgo/wallet/wallet.ts:2188
- [nitpick] The name 'keychainPromise' implies a single keychain, but the returned value is an array of keychains; consider renaming it to 'keychainsPromise' for clarity.
const keychainPromise = this.getKeychainsAndValidatePassphrase({
const results = await Promise.allSettled([keychainPromise, txPrebuildQuery]); | ||
|
||
// the prebuild can be overridden by providing an explicit tx | ||
const txPrebuild = (await txPrebuildQuery) as PrebuildTransactionResult; | ||
// Handle keychain promise (index 0) | ||
if (results[0].status === 'fulfilled') { | ||
keychains = results[0].value as Keychain[]; | ||
} else { | ||
throw results[0].reason; | ||
} | ||
|
||
// Handle txPrebuild promise (index 1) | ||
if (results[1].status === 'fulfilled') { | ||
txPrebuild = results[1].value as PrebuildTransactionResult; | ||
} else { | ||
throw results[1].reason; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider destructuring the results array into named variables (e.g., [keychainResult, txPrebuildResult]) for improved readability and to prevent potential confusion with index ordering.
Copilot uses AI. Check for mistakes.
Ticket: CAAS-7
prebuildAndSignTransaction
function to improve/sendcoins
endpoint performance