Skip to content

Commit

Permalink
feat: ttl_cache on _extract_abi_data (#856)
Browse files Browse the repository at this point in the history
* feat: ttl_cache on _extract_abi_data

* chore: `black .`

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
BobTheBuidler and github-actions[bot] authored Dec 15, 2024
1 parent e65018a commit de14cea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions y/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from brownie.network.state import _get_deployment
from brownie.typing import AccountsType
from brownie.utils import color
from cachetools.func import ttl_cache
from checksum_dict import ChecksumAddressSingletonMeta
from hexbytes import HexBytes
from msgspec.json import decode
Expand Down Expand Up @@ -935,6 +936,8 @@ def _squeeze(contract: Contract) -> Contract:
return contract


# we loosely cache this so we don't have to repeatedly fetch abis for commonly used proxy implementations
@ttl_cache(maxsize=1000, ttl=60 * 60)
@eth_retry.auto_retry
def _extract_abi_data(address: Address):
"""
Expand Down Expand Up @@ -1064,9 +1067,8 @@ def _resolve_proxy(address) -> Tuple[str, List]:
return name, abi


@alru_cache(
ttl=300
) # we loosely cache this so we don't have to repeatedly fetch abis for commonly used proxy implementations
# we loosely cache this so we don't have to repeatedly fetch abis for commonly used proxy implementations
@alru_cache(maxsize=1000, ttl=300)
async def _extract_abi_data_async(address: Address):
"""
Extract ABI data for a contract from the blockchain explorer.
Expand Down

0 comments on commit de14cea

Please sign in to comment.