-
Notifications
You must be signed in to change notification settings - Fork 543
Add RPC client PollTransaction with exponential backoff #5876
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
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 adds a PollTransaction method to the RPC client that provides a convenient way for callers to wait for transaction finalization. The method polls GetTransaction until the transaction reaches a terminal state (SUCCESS or FAILED) using exponential backoff, respecting context cancellation for timeout control. This eliminates the need for callers to implement their own polling logic.
Key changes:
- New
PollTransactionmethod with exponential backoff strategy - Configurable
PollTransactionOptionsfor customizing polling intervals - Comprehensive test suite covering success, failure, polling, timeout, and error scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| clients/rpcclient/main.go | Adds PollTransaction method, PollTransactionOptions struct with builder methods, and backoff configuration logic |
| clients/rpcclient/main_test.go | Adds comprehensive test coverage including success/failure cases, polling behavior, context timeout, and RPC error handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Shaptic
left a comment
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.
Very nice addition 👍
### What Replace custom backoff-based transaction polling logic with the Go Stellar SDK's built-in PollTransaction method. ### Why The go-stellar-sdk is getting PollTransaction functionality in stellar/go-stellar-sdk#5876, which is a port over of the polling transaction logic in friendbot. Now that the logic has been incorporated into the SDK, that eliminates the need for that logic to live and be maintained here. Dependent on: - #37 - stellar/go-stellar-sdk#5876
What
Add PollTransaction method to RPC client that polls GetTransaction until a terminal state (SUCCESS or FAILED) is reached. Use exponential backoff between attempts with configurable initial and max intervals. Respect context cancellation for timeout control.
Why
Callers need a convenient way to wait for transaction finalization without implementing their own polling logic and backoff strategy. We were adding this function to Friendbot, and @Shaptic pointed out that we could include this in the RPC client.
Close #5875