bittensor.utils.substrate_utils.storage#

Classes#

StorageKey

A StorageKey instance is a representation of a single state entry.

Module Contents#

class bittensor.utils.substrate_utils.storage.StorageKey(pallet, storage_function, params, data, value_scale_type, metadata, runtime_config)#

A StorageKey instance is a representation of a single state entry.

Substrate uses a simple key-value data store implemented as a database-backed, modified Merkle tree. All of Substrate’s higher-level storage abstractions are built on top of this simple key-value store.

Parameters:
  • pallet (Optional[str])

  • storage_function (Optional[str])

  • params (Optional[list])

  • data (Optional[bytes])

  • value_scale_type (Optional[str])

  • metadata (scalecodec.GenericMetadataVersioned)

  • runtime_config (scalecodec.base.RuntimeConfigurationObject)

convert_storage_parameter(scale_type, value)#
Parameters:
  • scale_type (str)

  • value (Any)

classmethod create_from_data(data, runtime_config, metadata, value_scale_type=None, pallet=None, storage_function=None)#

Create a StorageKey instance providing raw storage key bytes

Parameters:
  • data (bytes) – bytes representation of the storage key

  • runtime_config (scalecodec.base.RuntimeConfigurationObject) – RuntimeConfigurationObject

  • metadata (scalecodec.GenericMetadataVersioned) – GenericMetadataVersioned

  • value_scale_type (str) – type string of to decode result data

  • pallet (str) – name of pallet

  • storage_function (str) – name of storage function

Returns:

StorageKey

Return type:

StorageKey

classmethod create_from_storage_function(pallet, storage_function, params, runtime_config, metadata)#

Create a StorageKey instance providing storage function details

Parameters:
  • pallet (str) – name of pallet

  • storage_function (str) – name of storage function

  • params (list) – Optional list of parameters in case of a Mapped storage function

  • runtime_config (scalecodec.base.RuntimeConfigurationObject) – RuntimeConfigurationObject

  • metadata (scalecodec.GenericMetadataVersioned) – GenericMetadataVersioned

Returns:

StorageKey

Return type:

StorageKey

data#
decode_scale_value(data=None)#
Parameters:

data (Optional[scalecodec.ScaleBytes])

Return type:

scalecodec.base.ScaleType

generate()#

Generate a storage key for current specified pallet/function/params

Return type:

bytes

metadata#
metadata_storage_function = None#
pallet#
params#
params_encoded = []#
runtime_config#
storage_function#
to_hex()#

Returns a Hex-string representation of current StorageKey data

Returns:

Hex string

Return type:

Optional[str]

value_scale_type#