bittensor.utils.subtensor#

Module providing common helper functions for working with Subtensor.

Attributes#

Functions#

_get_errors_from_pallet(pallet)

Extracts and returns error information from the given pallet metadata.

_save_errors_to_cache(uniq_version, errors)

Saves error details and unique version identifier to a JSON file.

_get_errors_from_cache()

Retrieves and returns the cached error information from a JSON file, if it exists.

get_subtensor_errors(substrate)

Fetches or retrieves cached Subtensor error definitions using metadata.

format_parent(proportion, parent)

Formats raw parent data into a list of tuples.

format_children(children)

Formats raw children data into a list of tuples.

Module Contents#

bittensor.utils.subtensor._logger#
bittensor.utils.subtensor._USER_HOME_DIR#
bittensor.utils.subtensor._BT_DIR#
bittensor.utils.subtensor._ERRORS_FILE_PATH#
bittensor.utils.subtensor._ST_BUILD_ID = 'subtensor_build_id'#
bittensor.utils.subtensor._get_errors_from_pallet(pallet)[source]#

Extracts and returns error information from the given pallet metadata.

Parameters:

pallet (PalletMetadataV14) – The pallet metadata containing error definitions.

Returns:

A dictionary of errors indexed by their IDs.

Return type:

dict[str, str]

Raises:

ValueError – If the pallet does not contain error definitions or the list is empty.

bittensor.utils.subtensor._save_errors_to_cache(uniq_version, errors)[source]#

Saves error details and unique version identifier to a JSON file.

Parameters:
  • uniq_version (str) – Unique version identifier for the Subtensor build.

  • errors (dict[str, str]) – Error information to be cached.

bittensor.utils.subtensor._get_errors_from_cache()[source]#

Retrieves and returns the cached error information from a JSON file, if it exists.

Returns:

A dictionary containing error information.

Return type:

Optional[Dict[str, Dict[str, Dict[str, str]]]]

bittensor.utils.subtensor.get_subtensor_errors(substrate)[source]#

Fetches or retrieves cached Subtensor error definitions using metadata.

Parameters:

substrate (SubstrateInterface) – Instance of SubstrateInterface to access metadata.

Returns:

A dictionary containing error information.

Return type:

dict[str, str]

bittensor.utils.subtensor.format_parent(proportion, parent)[source]#

Formats raw parent data into a list of tuples. :param parent: The raw parent data. :param proportion: proportion of parent data.

Returns:

List of (proportion, child_address) tuples.

Return type:

list

bittensor.utils.subtensor.format_children(children)[source]#

Formats raw children data into a list of tuples. :param children: The raw children data.

Returns:

List of (proportion, child_address) tuples.

Return type:

list