async def fetch_block(self, request): """Fetches a specific block from the validator, specified by id. Request: path: - block_id: The 128-character id of the block to be fetched Response: data: A JSON object with the data from the fully expanded Block link: The link to this exact query """ error_traps = [error_handlers.BlockNotFoundTrap] block_id = request.match_info.get('block_id', '') self._validate_id(block_id) response = await self._query_validator( Message.CLIENT_BLOCK_GET_BY_ID_REQUEST, client_block_pb2.ClientBlockGetResponse, client_block_pb2.ClientBlockGetByIdRequest(block_id=block_id), error_traps) return self._wrap_response( request, data=self._expand_block(response['block']), metadata=self._get_metadata(request, response))
async def _head_to_root(self, block_id): error_traps = [error_handlers.BlockNotFoundTrap] if block_id: response = await self._messenger._query_validator( Message.CLIENT_BLOCK_GET_BY_ID_REQUEST, client_block_pb2.ClientBlockGetResponse, client_block_pb2.ClientBlockGetByIdRequest(block_id=block_id), error_traps) block = self._expand_block(response['block']) else: response = await self._messenger._query_validator( Message.CLIENT_BLOCK_LIST_REQUEST, client_block_pb2.ClientBlockListResponse, client_block_pb2.ClientBlockListRequest( paging=client_list_control_pb2.ClientPagingControls( limit=1)), error_traps) block = self._expand_block(response['blocks'][0]) return ( block['header_signature'], block['header']['state_root_hash'], )