Spaces:
Runtime error
Runtime error
| import asyncio | |
| import aiohttp | |
| async def get_nth_byte(n: int, ip: str = "65.109.145.104", port: int = 8091) -> bytes: | |
| """Fetch the nth byte from validator API""" | |
| print(f"Fetching byte at position {n}") | |
| async with aiohttp.ClientSession() as session: | |
| # Get just the single byte we want | |
| bits_url = f"http://{ip}:{port}/bits" | |
| headers = {'Range': f'bytes={n}-{n}'} | |
| async with session.get(bits_url, headers=headers, timeout=5) as resp: | |
| if resp.status != 206: | |
| raise Exception(f"Failed to get byte: {resp.status}") | |
| byte_data = await resp.read() | |
| if not byte_data: | |
| raise Exception("No data received") | |
| print(f"Got byte: {hex(byte_data[0])} (binary: {format(byte_data[0], '08b')})") | |
| return byte_data | |
| async def main(): | |
| try: | |
| # Get byte at position n | |
| n = 167371 # Change this to get different bytes | |
| byte_data = await get_nth_byte(n) | |
| except Exception as e: | |
| print(f"Error: {str(e)}") | |
| if __name__ == "__main__": | |
| asyncio.run(main()) | |