chore: parallellize keychain and queryPromise#6136
Merged
Conversation
e0befb2 to
7baae82
Compare
ppongbitgo
reviewed
May 16, 2025
8ecb7ea to
bbb3faa
Compare
c682e7c to
2ba5ea3
Compare
87c70b9 to
c829563
Compare
4bd8ccb to
037ee71
Compare
margueriteblair
previously approved these changes
May 20, 2025
ppongbitgo
reviewed
May 20, 2025
cd404c2
cd6d3e3 to
a8c3591
Compare
zahin-mohammad
requested changes
May 26, 2025
b3d5358 to
8728b12
Compare
ppongbitgo
reviewed
May 29, 2025
74898a8 to
87f8de4
Compare
zahin-mohammad
previously approved these changes
May 29, 2025
ppongbitgo
reviewed
May 29, 2025
344b4c7 to
5367fbb
Compare
ppongbitgo
approved these changes
May 29, 2025
zahin-mohammad
approved these changes
May 29, 2025
There was a problem hiding this comment.
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({
Comment on lines
+2207
to
+2220
| 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.
[nitpick] Consider destructuring the results array into named variables (e.g., [keychainResult, txPrebuildResult]) for improved readability and to prevent potential confusion with index ordering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket: CAAS-7
prebuildAndSignTransactionfunction to improve/sendcoinsendpoint performance