async def get_blockchain_state(self) -> Dict: response = await self.fetch("get_blockchain_state", {}) response["tips"] = [ Header.from_json_dict(tip) for tip in response["tips"] ] response["lca"] = Header.from_json_dict(response["lca"]) return response
async def get_header_by_height(self, header_height) -> Optional[Header]: try: response = await self.fetch("get_header_by_height", {"height": header_height}) except Exception: return None return Header.from_json_dict(response["header"])
async def get_header(self, header_hash) -> Optional[Header]: try: response = await self.fetch("get_header", {"header_hash": header_hash.hex()}) except aiohttp.client_exceptions.ClientResponseError as e: if e.message == "Not Found": return None raise return Header.from_json_dict(response)
async def get_header(self, header_hash) -> Optional[Header]: try: response = await self.fetch("get_header", {"header_hash": header_hash.hex()}) if response["header"] is None: return None except Exception: return None return Header.from_json_dict(response["header"])
async def get_unfinished_block_headers(self, height: uint32) -> List[Header]: response = await self.fetch("get_unfinished_block_headers", {"height": height}) return [Header.from_json_dict(r) for r in response["headers"]]
async def get_heaviest_block_seen(self) -> Header: response = await self.fetch("get_heaviest_block_seen", {}) return Header.from_json_dict(response["tip"])