Skip to content

Commit

Permalink
Increase ipfs timeouts (#124)
Browse files Browse the repository at this point in the history
Signed-off-by: cyc60 <[email protected]>

Signed-off-by: cyc60 <[email protected]>
  • Loading branch information
cyc60 authored Nov 17, 2022
1 parent e8c8126 commit 6e3eb71
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Empty file removed oracle/common/__init__.py
Empty file.
12 changes: 6 additions & 6 deletions oracle/oracle/common/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

logger = logging.getLogger(__name__)

timeout = ClientTimeout(total=60)
timeout = ClientTimeout(total=180)

CACHE_SIZE = 1024
IPFS_CACHE = LimitedSizeDict(size_limit=CACHE_SIZE)
Expand All @@ -41,24 +41,24 @@ async def _fetch(_ipfs_hash):
return await response.json()
except BaseException as e: # noqa: E722
logger.exception(e)
pass

if LOCAL_IPFS_CLIENT_ENDPOINT:
try:
with ipfshttpclient.connect(LOCAL_IPFS_CLIENT_ENDPOINT) as client:
return client.get_json(_ipfs_hash)
except ipfshttpclient.exceptions.TimeoutError:
pass
except BaseException as e: # noqa: E722
logger.exception(e)

try:
with ipfshttpclient.connect(
INFURA_IPFS_CLIENT_ENDPOINT,
username=INFURA_IPFS_CLIENT_USERNAME,
password=INFURA_IPFS_CLIENT_PASSWORD,
timeout=180,
) as client:
return client.get_json(_ipfs_hash)
except ipfshttpclient.exceptions.TimeoutError:
pass
except BaseException as e: # noqa: E722
logger.exception(e)

data = await _fetch(_ipfs_hash)
if data:
Expand Down
2 changes: 1 addition & 1 deletion oracle/oracle/distributor/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ async def upload_claims(claims: Claims) -> str:
INFURA_IPFS_CLIENT_ENDPOINT,
username=INFURA_IPFS_CLIENT_USERNAME,
password=INFURA_IPFS_CLIENT_PASSWORD,
timeout=180,
) as client:
ipfs_id = client.add_json(claims)
client.pin.add(ipfs_id)
Expand Down Expand Up @@ -107,7 +108,6 @@ async def upload_claims(claims: Claims) -> str:
ipfs_ids.append(ipfs_id)
except Exception as e: # noqa: E722
logger.error(e)
logger.error("Failed to submit claims to Pinata")

if not ipfs_ids:
raise RuntimeError("Failed to submit claims to IPFS")
Expand Down

0 comments on commit 6e3eb71

Please sign in to comment.