From add9dd78507d62eef701f8b0c018c22e686562d0 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 24 Mar 2023 20:31:09 +0000 Subject: [PATCH] rpc: make process_http_resp() non-async --- mmgen/proto/xmr/rpc.py | 4 ++-- mmgen/rpc.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mmgen/proto/xmr/rpc.py b/mmgen/proto/xmr/rpc.py index 59c1305c..fb8d2aba 100755 --- a/mmgen/proto/xmr/rpc.py +++ b/mmgen/proto/xmr/rpc.py @@ -53,7 +53,7 @@ class MoneroRPCClient(RPCClient): async def call(self,method,*params,**kwargs): assert params == (), f'{type(self).__name__}.call() accepts keyword arguments only' - return await self.process_http_resp(self.backend.run( + return self.process_http_resp(await self.backend.run( payload = {'id': 0, 'jsonrpc': '2.0', 'method': method, 'params': kwargs }, timeout = 3600, # allow enough time to sync ≈1,000,000 blocks host_path = '/json_rpc' @@ -67,7 +67,7 @@ class MoneroRPCClientRaw(MoneroRPCClient): async def call(self,method,*params,**kwargs): assert params == (), f'{type(self).__name__}.call() accepts keyword arguments only' - return await self.process_http_resp(self.backend.run( + return self.process_http_resp(await self.backend.run( payload = kwargs, timeout = self.timeout, host_path = f'/{method}' diff --git a/mmgen/rpc.py b/mmgen/rpc.py index 8980d513..562dc483 100755 --- a/mmgen/rpc.py +++ b/mmgen/rpc.py @@ -302,7 +302,7 @@ class RPCClient(MMGenObject): """ default call: call with param list unrolled, exactly as with cli """ - return await self.process_http_resp(self.backend.run( + return self.process_http_resp(await self.backend.run( payload = {'id': 1, 'jsonrpc': '2.0', 'method': method, 'params': params }, timeout = timeout, host_path = self.make_host_path(wallet) @@ -313,7 +313,7 @@ class RPCClient(MMGenObject): Make a single call with a list of tuples as first argument For RPC calls that return a list of results """ - return await self.process_http_resp(self.backend.run( + return self.process_http_resp(await self.backend.run( payload = [{ 'id': n, 'jsonrpc': '2.0', @@ -337,15 +337,15 @@ class RPCClient(MMGenObject): ret = [] while cur_pos < len(cmd_list): - tasks = [self.process_http_resp(self.backend.run( + tasks = [self.backend.run( payload = {'id': n, 'jsonrpc': '2.0', 'method': method, 'params': params }, timeout = timeout, host_path = self.make_host_path(wallet) - )) for n,(method,params) in enumerate(cmd_list[cur_pos:chunk_size+cur_pos],1)] + ) for n,(method,params) in enumerate(cmd_list[cur_pos:chunk_size+cur_pos],1)] ret.extend(await asyncio.gather(*tasks)) cur_pos += chunk_size - return ret + return [self.process_http_resp(r) for r in ret] # Icall family of methods - indirect RPC call using CallSigs mechanism: # - 'timeout' and 'wallet' kwargs are passed to corresponding Call method @@ -367,8 +367,8 @@ class RPCClient(MMGenObject): timeout = timeout, wallet = wallet ) - async def process_http_resp(self,coro,batch=False): - text,status = await coro + def process_http_resp(self,run_ret,batch=False,json_rpc=True): + text,status = run_ret if status == 200: dmsg_rpc(' RPC RESPONSE data ==>\n{}\n',text,is_json=True) if batch: