Skip to content

Commit

Permalink
Bypass ipfs hash validation for large files
Browse files Browse the repository at this point in the history
  • Loading branch information
njgheorghita committed Jul 19, 2019
1 parent e50470e commit c4c5f57
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ethpm/backends/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@ def __init__(self) -> None:
def fetch_uri_contents(self, uri: str) -> bytes:
ipfs_hash = extract_ipfs_path_from_uri(uri)
contents = self.client.cat(ipfs_hash)
validation_hash = generate_file_hash(contents)
if validation_hash != ipfs_hash:
raise EthPMValidationError(
f"Hashed IPFS contents retrieved from uri: {uri} do not match its content hash."
)
# Local validation of hashed contents only works for non-chunked files ~< 256kb
# Improved validation WIP @ https://github.com/ethpm/py-ethpm/pull/165
if len(contents) <= 262144:
validation_hash = generate_file_hash(contents)
if validation_hash != ipfs_hash:
raise EthPMValidationError(
f"Hashed IPFS contents retrieved from uri: {uri} do not match its content hash."
)
return contents

@property
Expand Down

0 comments on commit c4c5f57

Please sign in to comment.