Skip to content

Commit ea4b1fe

Browse files
author
Roman
committed
add await, improve logic async
1 parent 0fb502b commit ea4b1fe

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

bittensor/core/async_subtensor.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -799,15 +799,15 @@ async def all_subnets(
799799
subnets = await subtensor.all_subnets()
800800
"""
801801
block_hash = await self.determine_block_hash(
802-
block_number, block_hash, reuse_block
802+
block=block_number, block_hash=block_hash, reuse_block=reuse_block
803803
)
804804
if not block_hash and reuse_block:
805805
block_hash = self.substrate.last_block_hash
806806

807807
query, subnet_prices = await asyncio.gather(
808808
self.substrate.runtime_call(
809-
"SubnetInfoRuntimeApi",
810-
"get_all_dynamic_info",
809+
api="SubnetInfoRuntimeApi",
810+
method="get_all_dynamic_info",
811811
block_hash=block_hash,
812812
),
813813
self.get_subnet_prices(),
@@ -3733,7 +3733,9 @@ async def subnet(
37333733
Returns:
37343734
Optional[DynamicInfo]: A DynamicInfo object, containing detailed information about a subnet.
37353735
"""
3736-
block_hash = await self.determine_block_hash(block, block_hash, reuse_block)
3736+
block_hash = await self.determine_block_hash(
3737+
block=block, block_hash=block_hash, reuse_block=reuse_block
3738+
)
37373739

37383740
if not block_hash and reuse_block:
37393741
block_hash = self.substrate.last_block_hash
@@ -3746,7 +3748,15 @@ async def subnet(
37463748
)
37473749

37483750
if isinstance(decoded := query.decode(), dict):
3749-
price = self.get_subnet_price(netuid=netuid, block=block)
3751+
try:
3752+
price = await self.get_subnet_price(
3753+
netuid=netuid,
3754+
block=block,
3755+
block_hash=block_hash,
3756+
reuse_block=reuse_block,
3757+
)
3758+
except SubstrateRequestException:
3759+
price = None
37503760
return DynamicInfo.from_dict({**decoded, "price": price})
37513761
return None
37523762

0 commit comments

Comments
 (0)