Skip to content

Commit

Permalink
Fixed a bug in the get_subnets function (again)
Browse files Browse the repository at this point in the history
"Fixed a bug in the get_subnets function where pagination led to truncated results. The function now iterates through the entire result set, loading all items into memory without pagination issues.
  • Loading branch information
niljub committed Aug 20, 2024
1 parent 65aa008 commit ad1c35a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bittensor/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4254,9 +4254,13 @@ def get_subnets(self, block: Optional[int] = None) -> List[int]:
"""
result = self.query_map_subtensor("NetworksAdded", block)
subnets = []
if result and hasattr(result, "records"):
for record in result.records:
subnets.append(record[0].value)

for data in result:
continue
# Check if the 'records' attribute exists and is not None
if hasattr(result, "records") and result.records:
subnets = [subnet[0].value for subnet in result.records]

return subnets

def get_all_subnets_info(self, block: Optional[int] = None) -> List[SubnetInfo]:
Expand Down

0 comments on commit ad1c35a

Please sign in to comment.