Skip to content

Conversation

@leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Dec 5, 2025

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

Copy link
Contributor

Copilot AI left a 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 PollTransaction method with exponential backoff strategy
  • Configurable PollTransactionOptions for 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.

@sreuland sreuland changed the base branch from master to main December 11, 2025 00:25
@leighmcculloch leighmcculloch marked this pull request as ready for review January 6, 2026 02:31
@leighmcculloch leighmcculloch requested a review from a team January 6, 2026 02:32
@leighmcculloch leighmcculloch enabled auto-merge (squash) January 6, 2026 21:53
@leighmcculloch leighmcculloch requested a review from Shaptic January 6, 2026 21:53
Copy link
Contributor

@Shaptic Shaptic left a comment

Choose a reason for hiding this comment

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

Very nice addition 👍

@leighmcculloch leighmcculloch merged commit c77f40a into main Jan 6, 2026
11 checks passed
@leighmcculloch leighmcculloch deleted the add-rpc-poll-transaction-method branch January 6, 2026 22:55
leighmcculloch added a commit to stellar/friendbot that referenced this pull request Jan 9, 2026
### 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add transaction polling method to RPC client

3 participants