Skip to content

Commit 3c77590

Browse files
author
Roman
committed
add the check if field_indices is correct data
1 parent bb60333 commit 3c77590

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

bittensor/core/async_subtensor.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,8 +1503,15 @@ async def get_metagraph_info(
15031503
"""
15041504
indices = SelectiveMetagraphIndex.all_indices()
15051505

1506-
if field_indices and isinstance(field_indices, list):
1507-
indices = [f.value for f in field_indices]
1506+
if field_indices:
1507+
if isinstance(field_indices, list) and all(
1508+
isinstance(f, SelectiveMetagraphIndex) for f in field_indices
1509+
):
1510+
indices = [f.value for f in field_indices]
1511+
else:
1512+
raise ValueError(
1513+
"`field_indices` must be a list of SelectiveMetagraphIndex items."
1514+
)
15081515

15091516
block_hash = await self.determine_block_hash(block, block_hash, reuse_block)
15101517
if not block_hash and reuse_block:

bittensor/core/subtensor.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,8 +1160,15 @@ def get_metagraph_info(
11601160
"""
11611161
indices = SelectiveMetagraphIndex.all_indices()
11621162

1163-
if field_indices and isinstance(field_indices, list):
1164-
indices = [f.value for f in field_indices]
1163+
if field_indices:
1164+
if isinstance(field_indices, list) and all(
1165+
isinstance(f, SelectiveMetagraphIndex) for f in field_indices
1166+
):
1167+
indices = [f.value for f in field_indices]
1168+
else:
1169+
raise ValueError(
1170+
"`field_indices` must be a list of SelectiveMetagraphIndex items."
1171+
)
11651172

11661173
block_hash = self.determine_block_hash(block)
11671174
query = self.substrate.runtime_call(

0 commit comments

Comments
 (0)