Skip to content

Commit

Permalink
Add set_block_tip_latency
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Oct 2, 2023
1 parent bb671d0 commit 0567d5f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.22.17

- Add ``eth_defi.broken_provider.set_block_tip_latency()`` to control the default delays
for which we expect the chain tip to stabilise.

# 0.22.16

- Work around ``BadFunctionCallOutput``: Insufficient bytes exception: A special case of eth_call returning an empty result.
Expand Down
19 changes: 17 additions & 2 deletions eth_defi/provider/broken_provider.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"""Fixes for Ankr and other broken JSON-RPC service providers.
"""Fixes and workaronds for various JSON-RPC service providers.
- Mainly to deal with unstable blockchain chain tip
- See also :py:mod:`eth_defi.provider.ankr`
See also
- :py:mod:`eth_defi.provider.fallback`
- :py:mod:`eth_defi.provider.ankr`
"""
from eth_defi.provider.ankr import is_ankr
Expand Down Expand Up @@ -70,3 +74,14 @@ def get_block_tip_latency(web3: Web3) -> int:
return latency_override

return get_default_block_tip_latency(web3)


def set_block_tip_latency(web3: Web3, block_count: int):
"""Override the default block tip latency settings.
Useful for unit testing, because unit testing assumes stuff
has happened in the latest block you want to read.
See :py:func:`get_block_tip_latency`.
"""
web3.block_tip_latency = block_count
2 changes: 1 addition & 1 deletion eth_defi/provider/llamanodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Fixes for quirks and features on LlamaNodes.
"""LlamaNodes specific Python code.
- `LlamaNodes <https://llamanodes.com/>`__ runs RPC services at ``llamarpc.com``
Expand Down

0 comments on commit 0567d5f

Please sign in to comment.