Skip to content

Commit

Permalink
fix: hotfix intermittent errors in raw calls (#312)
Browse files Browse the repository at this point in the history
* fix: hotfix intermittent errors in raw calls

* Update eth.py
  • Loading branch information
BobTheBuidler authored Dec 4, 2024
1 parent 0b81662 commit 1ad57e2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dank_mids/eth.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from typing import (
Awaitable,
Callable,
Expand Down Expand Up @@ -187,7 +188,12 @@ async def trace_filter(
Raises:
ValidationError: If a trace cannot be decoded.
"""
traces_bytes = await self._trace_filter(filter_params)
attempts = 0
traces_bytes = None
# TODO: figure out a better way to handle intermittent errors
while (traces_bytes := await self._trace_filter(filter_params)) is None and attempts < 5:
attempts += 1
await asyncio.sleep(1)
try:
return json.decode(traces_bytes, type=decode_to, dec_hook=decode_hook)
except ValidationError:
Expand Down Expand Up @@ -255,7 +261,12 @@ async def get_logs(
decode_hook: Hook function to assist in decoding.
**kwargs: Additional keyword arguments.
"""
logs_bytes = await self._get_logs_raw(*args, **kwargs) # type: ignore [attr-defined]
attempts = 0
logs_bytes = None
# TODO: figure out a better way to handle intermittent errors
while (logs_bytes := await self._get_logs_raw(*args, **kwargs)) is None and attempts < 5: # type: ignore [attr-defined]
attempts += 1
await asyncio.sleep(1)
return json.decode(logs_bytes, type=decode_to, dec_hook=decode_hook)

meth = MethodNoFormat.default(RPC.eth_getTransactionReceipt) # type: ignore [arg-type, var-annotated]
Expand Down

0 comments on commit 1ad57e2

Please sign in to comment.