aea.helpers.ipfs.base
This module contains helper methods and classes for the 'aea' package.
SHA256_
ID
0x12
LEN_
SHA256
0x20
chunks
def chunks(data: Sized, size: int) -> Generator
Yield successivesize chunks from data.
IPFSHashOnly Objects
class IPFSHashOnly()
A helper class which allows construction of an IPFS hash without interacting with an IPFS daemon.
get
@classmethod
def get(cls, file_path: str, wrap: bool = True, cid_v1: bool = True) -> str
Get the IPFS hash.
hash_
file
@classmethod
def hash_file(cls,
file_path: str,
wrap: bool = True,
cid_v1: bool = True) -> str
Get the IPFS hash for a single file.
Arguments:
file_path
: the file pathwrap
: whether to wrap the content in wrapper node or notcid_v1
: whether to use CID v1 hashes
Returns:
the ipfs hash
hash_
bytes
@classmethod
def hash_bytes(cls,
data: bytes,
wrap: bool = True,
cid_v1: bool = True,
file_name_if_wrap: Optional[str] = None) -> str
Get the IPFS hash for a single file.
Arguments:
data
: byteswrap
: whether to wrap the content in wrapper node or notcid_v1
: whether to use CID v1 hashesfile_name_if_wrap
: optional str with filename applied if wrap is True
Returns:
the ipfs hash
hash_
directory
@classmethod
def hash_directory(cls,
dir_path: str,
wrap: bool = True,
cid_v1: bool = True) -> str
Get the IPFS hash for a directory.
Arguments:
dir_path
: the directory pathwrap
: whether to wrap the content in wrapper node or notcid_v1
: whether to use CID v1 hashes
Returns:
the ipfs hash
create_
link
@staticmethod
def create_link(link_hash: bytes, tsize: int, name: str) -> Any
Create PBLink object.
wrap_
in_
a_
node
@classmethod
def wrap_in_a_node(cls, link: Any) -> str
Wrap content in a wrapper node.