Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions oocana/oocana/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,33 @@ def response_callback(payload: Dict[str, Any]):

return await f

async def query_auth(self, id: str) -> Dict[str, Any]:
request_id = random_string(16)
loop = asyncio.get_running_loop()
f: asyncio.Future[Dict[str, Any]] = loop.create_future()

def response_callback(payload: Dict[str, Any]):
if payload.get("request_id") != request_id:
return
self.__mainframe.remove_request_response_callback(self.session_id, request_id, response_callback)
if payload.get("result") is not None:
loop.call_soon_threadsafe(lambda: f.set_result(payload.get("result", {})))
elif payload.get("error") is not None:
loop.call_soon_threadsafe(lambda: f.set_exception(ValueError(payload.get("error", "Unknown error occurred while querying the auth."))))

self.__mainframe.add_request_response_callback(self.session_id, request_id, response_callback)

self.__mainframe.send(self.job_info, {
"type": "BlockRequest",
"action": "QueryAuth",
"id": id,
"session_id": self.session_id,
"job_id": self.job_id,
"request_id": request_id,
})

return await f

async def query_block(self, block: str) -> QueryBlockResponse:
"""
this is a experimental api, it is used to query the block information..
Expand Down