Skip to content

Commit

Permalink
Move Ankr to its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Sep 19, 2023
1 parent 93791a8 commit db60c80
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 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.10

- Move Ankr specific functionality to its own `eth_defi.provider.ankr` module
that will see more changes in the future

# 0.22.9

- Add `eth_defi.rpc.broken_provider` for workaround for the quirks and features of different JSON-RPC providers
Expand Down
2 changes: 2 additions & 0 deletions docs/source/api/provider/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ This submodule offers functionality to connect and enhance robustness of various
eth_defi.provider.multi_provider
eth_defi.provider.mev_blocker
eth_defi.provider.fallback
eth_defi.provider.broken_provider
eth_defi.provider.ankr
eth_defi.provider.anvil
eth_defi.provider.ganache
eth_defi.provider.named
Expand Down
19 changes: 19 additions & 0 deletions eth_defi/provider/ankr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Ankr specific Web3.py functionality.
- Ankr has issues with some JSON-RPC access patterns.
See also :py:mod:`eth_defi.rpc.broken_provider`.
"""
from web3 import Web3

from eth_defi.provider.named import get_provider_name


def is_ankr(web3: Web3) -> bool:
"""Are we connected to Ankr as a provider.
We use this function to detect and activate Ankr workarounds
for their bugs and features.
"""
name = get_provider_name(web3.provider)
return name == "rpc.ankr.com"
12 changes: 4 additions & 8 deletions eth_defi/provider/broken_provider.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
"""Fixes for Ankr and other broken JSON-RPC service providers.
- Mainly to deal with unstable blockchain chain tip
"""

from eth_defi.provider.named import get_provider_name
from web3 import Web3
- See also :py:mod:`eth_defi.provider.ankr`
def is_ankr(web3: Web3) -> bool:
"""Are we connected to Ankr as a provider."""
name = get_provider_name(web3.provider)
return name == "rpc.ankr.com"
"""
from eth_defi.provider.ankr import is_ankr
from web3 import Web3


def get_default_block_tip_latency(web3: Web3) -> int:
Expand Down

0 comments on commit db60c80

Please sign in to comment.