bittensor.core.extrinsics.serving#
Functions#
|
Internal method to submit a serve axon transaction to the Bittensor blockchain. This method creates and submits a transaction, enabling a neuron's |
|
Subscribes a Bittensor endpoint to the subtensor chain. |
|
Serves the axon to the network. |
|
Publishes metadata on the Bittensor network using the specified wallet and network identifier. |
|
Module Contents#
- bittensor.core.extrinsics.serving.do_serve_axon(self, wallet, call_params, wait_for_inclusion=False, wait_for_finalization=True)[source]#
Internal method to submit a serve axon transaction to the Bittensor blockchain. This method creates and submits a transaction, enabling a neuron’s
Axon
to serve requests on the network.- Parameters:
self (bittensor.core.subtensor.Subtensor) – Subtensor instance object.
wallet (bittensor_wallet.Wallet) – The wallet associated with the neuron.
call_params (bittensor.core.types.AxonServeCallParams) – Parameters required for the serve axon call.
wait_for_inclusion (bool) – Waits for the transaction to be included in a block.
wait_for_finalization (bool) – Waits for the transaction to be finalized on the blockchain.
- Returns:
A tuple containing a success flag and an optional error message.
- Return type:
This function is crucial for initializing and announcing a neuron’s
Axon
service on the network, enhancing the decentralized computation capabilities of Bittensor.
- bittensor.core.extrinsics.serving.serve_extrinsic(subtensor, wallet, ip, port, protocol, netuid, placeholder1=0, placeholder2=0, wait_for_inclusion=False, wait_for_finalization=True, prompt=False)[source]#
Subscribes a Bittensor endpoint to the subtensor chain.
- Parameters:
subtensor (bittensor.core.subtensor.Subtensor) – Subtensor instance object.
wallet (bittensor_wallet.Wallet) – Bittensor wallet object.
ip (str) – Endpoint host port i.e.,
192.122.31.4
.port (int) – Endpoint port number i.e.,
9221
.protocol (int) – An
int
representation of the protocol.netuid (int) – The network uid to serve on.
placeholder1 (int) – A placeholder for future use.
placeholder2 (int) – A placeholder for future use.
wait_for_inclusion (bool) – If set, waits for the extrinsic to enter a block before returning
true
, or returnsfalse
if the extrinsic fails to enter the block within the timeout.wait_for_finalization (bool) – If set, waits for the extrinsic to be finalized on the chain before returning
true
, or returnsfalse
if the extrinsic fails to be finalized within the timeout.prompt (bool) – If
true
, the call waits for confirmation from the user before proceeding.
- Returns:
Flag is
true
if extrinsic was finalized or uncluded in the block. If we did not wait for finalization / inclusion, the response istrue
.- Return type:
success (bool)
- bittensor.core.extrinsics.serving.serve_axon_extrinsic(subtensor, netuid, axon, wait_for_inclusion=False, wait_for_finalization=True)[source]#
Serves the axon to the network.
- Parameters:
subtensor (bittensor.core.subtensor.Subtensor) – Subtensor instance object.
netuid (int) – The
netuid
being served on.axon (bittensor.core.axon.Axon) – Axon to serve.
wait_for_inclusion (bool) – If set, waits for the extrinsic to enter a block before returning
true
, or returnsfalse
if the extrinsic fails to enter the block within the timeout.wait_for_finalization (bool) – If set, waits for the extrinsic to be finalized on the chain before returning
true
, or returnsfalse
if the extrinsic fails to be finalized within the timeout.
- Returns:
Flag is
true
if extrinsic was finalized or uncluded in the block. If we did not wait for finalization / inclusion, the response istrue
.- Return type:
success (bool)
- bittensor.core.extrinsics.serving.publish_metadata(self, wallet, netuid, data_type, data, wait_for_inclusion=False, wait_for_finalization=True)[source]#
Publishes metadata on the Bittensor network using the specified wallet and network identifier.
- Parameters:
self (bittensor.core.subtensor.Subtensor) – The subtensor instance representing the Bittensor blockchain connection.
wallet (bittensor_wallet.Wallet) – The wallet object used for authentication in the transaction.
netuid (int) – Network UID on which the metadata is to be published.
data_type (str) – The data type of the information being submitted. It should be one of the following:
'Sha256'
,'Blake256'
,'Keccak256'
, or'Raw0-128'
. This specifies the format or hashing algorithm used for the data.data (str) – The actual metadata content to be published. This should be formatted or hashed according to the
type
specified. (Note: maxstr
length is 128 bytes)wait_for_inclusion (bool) – If
True
, the function will wait for the extrinsic to be included in a block before returning. Defaults toFalse
.wait_for_finalization (bool) – If
True
, the function will wait for the extrinsic to be finalized on the chain before returning. Defaults toTrue
.
- Returns:
True
if the metadata was successfully published (and finalized if specified).False
otherwise.- Return type:
- Raises:
MetadataError – If there is an error in submitting the extrinsic or if the response from the blockchain indicates failure.