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

Add a pollTransaction variation to support polling after sends #1092

Merged
merged 5 commits into from
Oct 28, 2024

Conversation

Shaptic
Copy link
Contributor

@Shaptic Shaptic commented Oct 24, 2024

What

Add a method to rpc.Server that lets you retry getTransaction based on your parameters. By default it tries 5 times with 1s of sleep between each polling attempt. However, it's flexible and you can do unhinged stuff like this:

const txStatus = await server.pollTransaction("cafebabe", {
   attempts: 100, // I'm a maniac
   sleepStrategy: rpc.LinearSleepStrategy
}); // this will take 5,050 seconds to complete

Note: I don't think this makes sense to do sending as well since it's a two-step process.

Copy link

github-actions bot commented Oct 24, 2024

Size Change: +112 kB (+0.23%)

Total Size: 49.1 MB

Filename Size Change
dist/stellar-sdk-minimal.js 6.76 MB +18.8 kB (+0.28%)
dist/stellar-sdk-minimal.min.js 5.28 MB +9.19 kB (+0.17%)
dist/stellar-sdk-no-axios.js 6.76 MB +18.8 kB (+0.28%)
dist/stellar-sdk-no-axios.min.js 5.28 MB +9.19 kB (+0.17%)
dist/stellar-sdk-no-eventsource.js 7.02 MB +18.8 kB (+0.27%)
dist/stellar-sdk-no-eventsource.min.js 5.49 MB +9.19 kB (+0.17%)
dist/stellar-sdk.js 7.02 MB +18.8 kB (+0.27%)
dist/stellar-sdk.min.js 5.49 MB +9.19 kB (+0.17%)

compressed-size-action

Copy link
Contributor

@kalepail kalepail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with the one caveat that 5 seconds is probably too short for a default. Ledgers are more often 6 seconds than 5 these days. I'd opt for a 30 second default.

@Shaptic Shaptic merged commit 36fa2af into master Oct 28, 2024
11 checks passed
@Shaptic Shaptic deleted the retry-getTransaction branch October 28, 2024 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants