Skip to content

Commit

Permalink
Retry on get_receipt_block_timestamp (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored Feb 19, 2025
1 parent 3149992 commit 1f1af27
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions prediction_market_agent_tooling/tools/web3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ def byte32_to_ipfscidv0(hex: HexBytes) -> IPFSCIDVersion0:
return IPFSCIDVersion0(base58.b58encode(completed_binary_str).decode("utf-8"))


@tenacity.retry(
wait=tenacity.wait_chain(*[tenacity.wait_fixed(n) for n in range(1, 10)]),
stop=tenacity.stop_after_attempt(5),
after=lambda x: logger.debug(
f"get_receipt_block_timestamp failed, {x.attempt_number=}."
),
)
def get_receipt_block_timestamp(receipt_tx: TxReceipt, web3: Web3) -> int:
block_number = receipt_tx["blockNumber"]
block = web3.eth.get_block(block_number)
Expand Down

0 comments on commit 1f1af27

Please sign in to comment.