blockchain.utils package¶
Submodules¶
blockchain.utils.constants module¶
blockchain.utils.errors module¶
-
exception
blockchain.utils.errors.ChainNotFoundError[source]¶ Bases:
ExceptionError if no local chain could be found.
-
exception
blockchain.utils.errors.ChainNotValidError[source]¶ Bases:
ExceptionError if loaded chain is not valid.
-
exception
blockchain.utils.errors.PortValueError[source]¶ Bases:
ValueErrorError if given port is out af valid range (1 - 65535).
blockchain.utils.utils module¶
-
class
blockchain.utils.utils.Job(interval: datetime.timedelta, execute, *args, **kwargs)[source]¶ Bases:
threading.Thread
-
blockchain.utils.utils.create_proper_url_string(host_port: (<class 'str'>, <class 'int'>), path: str) → str[source]¶ Takes the internal representation of neighbours and a endpoint path to create a proper URL string for requests.
Parameters: Returns: Correct URL string for
addressandpath.Return type:
-
blockchain.utils.utils.encode_file_path_properly(file_path: str) → str[source]¶ Encode each and every input filepath as absolute pathes.
Parameters: file_path (str) – Path to encode properly Returns: Absolute and properly encoded file_pathReturn type: str
-
blockchain.utils.utils.signal_handler(signum, frame)[source]¶ Signal handler used to raise special
ProgramKilledError.Raises: ProgramKilledError– To intercept for graceful shutdown.
-
blockchain.utils.utils.split_url_string(host_port: str) -> (<class 'str'>, <class 'int'>)[source]¶ Parses the given URL string and returns the IP address/hostname and the port/default port.
Parameters: host_port (str) – Representation of the miner as URL string, e.g.:
127.0.0.1:12345,miner1:8888,miner,http://localhost, …Returns: Tuple of IPv4 Address or hostname string and port number.
Return type: Raises: PortValueError– Will be raised if givenportis out of range.AddressValueError– Will be raised if givenaddressis not a valid IPv4 address or “localhost”.