Skip to content

Commit 4b8fef8

Browse files
author
Roman
committed
add get_subnet_info to subtensors
1 parent fb51b48 commit 4b8fef8

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

bittensor/core/async_subtensor.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,42 @@ async def get_stake_add_fee(
19211921
)
19221922
return Balance.from_rao(result)
19231923

1924+
async def get_subnet_info(
1925+
self,
1926+
netuid: int,
1927+
block: Optional[int] = None,
1928+
block_hash: Optional[str] = None,
1929+
reuse_block: bool = False,
1930+
) -> Optional["SubnetInfo"]:
1931+
"""
1932+
Retrieves detailed information about subnet within the Bittensor network.
1933+
This function provides comprehensive data on subnet, including its characteristics and operational parameters.
1934+
1935+
Arguments:
1936+
netuid: The unique identifier of the subnet.
1937+
block: The blockchain block number for the query.
1938+
block_hash (Optional[str]): The hash of the block to retrieve the stake from. Do not specify if using block
1939+
or reuse_block
1940+
reuse_block (bool): Whether to use the last-used block. Do not set if using block_hash or block.
1941+
1942+
Returns:
1943+
SubnetInfo: A SubnetInfo objects, each containing detailed information about a subnet.
1944+
1945+
Gaining insights into the subnet's details assists in understanding the network's composition, the roles of
1946+
different subnets, and their unique features.
1947+
"""
1948+
result = await self.query_runtime_api(
1949+
runtime_api="SubnetInfoRuntimeApi",
1950+
method="get_subnet_info_v2",
1951+
params=[netuid],
1952+
block=block,
1953+
block_hash=block_hash,
1954+
reuse_block=reuse_block,
1955+
)
1956+
if not result:
1957+
return None
1958+
return SubnetInfo.from_dict(result)
1959+
19241960
async def get_unstake_fee(
19251961
self,
19261962
amount: Balance,

bittensor/core/subtensor.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,33 @@ def get_stake_add_fee(
15071507
)
15081508
return Balance.from_rao(result)
15091509

1510+
def get_subnet_info(
1511+
self, netuid: int, block: Optional[int] = None
1512+
) -> Optional["SubnetInfo"]:
1513+
"""
1514+
Retrieves detailed information about subnet within the Bittensor network.
1515+
This function provides comprehensive data on subnet, including its characteristics and operational parameters.
1516+
1517+
Arguments:
1518+
netuid: The unique identifier of the subnet.
1519+
block: The blockchain block number for the query.
1520+
1521+
Returns:
1522+
SubnetInfo: A SubnetInfo objects, each containing detailed information about a subnet.
1523+
1524+
Gaining insights into the subnet's details assists in understanding the network's composition, the roles of
1525+
different subnets, and their unique features.
1526+
"""
1527+
result = self.query_runtime_api(
1528+
runtime_api="SubnetInfoRuntimeApi",
1529+
method="get_subnet_info_v2",
1530+
params=[netuid],
1531+
block=block,
1532+
)
1533+
if not result:
1534+
return None
1535+
return SubnetInfo.from_dict(result)
1536+
15101537
def get_unstake_fee(
15111538
self,
15121539
amount: Balance,

0 commit comments

Comments
 (0)