Skip to content

Conversation

@jasonpaulos
Copy link
Contributor

Fixes the following issues with the wait for confirmation function:

  1. pool-error was being ignored
  2. If the call to pending_transaction_info raises an HTTP error, that error should be ignored and the function should continue retrying if wait_rounds allows it.
  3. Removed the special value 0 for wait_rounds which allows indefinitely waiting. This is a dangerous feature, since your code might actually wait forever if it never sees the transaction fail. Instead a value of 1000 (the maximum txn life) is used to implement the same thing, and in reality is the longest you will ever have to wait. (Because v1.8.0 of this SDK was already released with this function, we can't get rid of the default value altogether without breaking the API).
  4. Remove f-string use, which is not available in Python 3.5


def wait_for_confirmation(algod_client, txid, wait_rounds=0, **kwargs):
def wait_for_confirmation(
algod_client: algod.AlgodClient, txid: str, wait_rounds: int = 0, **kwargs
Copy link
Contributor

Choose a reason for hiding this comment

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

Set the default value here instead of checking for 0 and overriding it.

A smaller default like 5 would probably be better default than 1000.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is my attempt at maintaining backwards compatibility, since we already shipped a version with this function (unlike the other SDKs).

There might be existing code that passes 0 for wait_rounds and expects the function to wait indefinitely, so I though 1000 was the best replacement for it.

@jasonpaulos jasonpaulos merged commit 5ca32ce into develop Dec 7, 2021
@jasonpaulos jasonpaulos deleted the fix-wait-for-confirmation branch December 7, 2021 21:03
aldur pushed a commit that referenced this pull request Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants