Add support for continually adding more txns to TransactionWorker, make it more extensible#675
Closed
Add support for continually adding more txns to TransactionWorker, make it more extensible#675
Conversation
be9282e to
e452bd6
Compare
0xmaayan
reviewed
Apr 5, 2025
Contributor
0xmaayan
left a comment
There was a problem hiding this comment.
LGTM, would like to see tests, and updated example https://github.com/aptos-labs/aptos-ts-sdk/blob/main/examples/typescript/batch_funds.ts
Contributor
Author
There was a problem hiding this comment.
Unintentional, probably from using a newer pnpm version. I'll revert it.
| this.run(); | ||
|
|
||
| Promise.all([this.submitNextTransaction(), this.processTransactions()]).catch((error) => { | ||
| console.error(`Transaction worker failed: ${error}`); |
Contributor
Author
There was a problem hiding this comment.
We should, mb, this is cursor's doing lol.
| * @category Transactions | ||
| */ | ||
| outstandingTransactions = new AsyncQueue<[Promise<PendingTransactionResponse>, bigint]>(); | ||
| outstandingTransactionHashes = new AsyncQueue<[Promise<string>, bigint]>(); |
Contributor
There was a problem hiding this comment.
could we add comments on what are the string, bigint types
3e665e7 to
d71bda0
Compare
…ke it more extensible
d71bda0 to
88030ed
Compare
Contributor
Author
|
Deprecating this in favor of #679. |
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.
Description
The existing behavior of the TransactionWorker is after it runs out of txns to submit, it no longer processes any further txns. This makes the class less useful, and given the existing API design, is quite unexpected, since the
pushmethod would still work, the worker wouldn't exit, etc.This PR makes the worker continually accept new transactions and submit them as they come in.
I also make some other improvements:
dequeueAllmethod toAsyncQueueso we don't have to replicate the functionality inprocessTransactionswith a for-loop.buildSignAndSubmitTransactionPromisemethod that can be overridden.Test Plan
See updated tests for the TransactionWorker and AsyncQueue. See also this run of the batch funds example:
Related Links
Checklist
pnpm fmt?CHANGELOG.md?