Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if inspect.iscoroutinefunction(f):
future = f(*args, **kwargs)
else:
coroutine = asyncio.coroutine(f)
future = coroutine(*args, **kwargs)
asyncio.get_event_loop().run_until_complete(future)
return wrapper
class MyMethods:
async def foo(self):
return "bar"
methods.add(MyMethods().foo)
class TestCall(TestCase):
@async_test
async def test_request(self):
req = AsyncRequest({"jsonrpc": "2.0", "method": "foo", "id": 1})
response = await req.call(methods)
self.assertEqual("bar", response["result"])
methods.add(self.estimatesmartfee)
methods.add(self.getbestblockhash)
methods.add(self.getblockchaininfo)
methods.add(self.getblockheader)
methods.add(self.getblockhash)
methods.add(self.getblock)
methods.add(self.getblockcount)
methods.add(self.getrawtransaction)
methods.add(self.gettxout)
methods.add(self.getpeerinfo)
methods.add(self.sendrawtransaction)
methods.add(self.stop)
methods.add(self.getmempoolinfo)
methods.add(self.getchaintxstats)
methods.add(self.getmininginfo)
methods.add(self.getrawmempool)
methods.add(self.getnetworkinfo)
methods.add(self.uptime)
methods.add(self.getnettotals)
methods.add(self.validateaddress)
methods.add(self.dev_memorysummary, name="dev-gc-stats")
methods.add(self.dev_collect, name="dev-gc-collect")
return await web.TCPSite(runner, host=self.host, port=self.port).start()
methods.add(self.getbestblockhash)
methods.add(self.getblockchaininfo)
methods.add(self.getblockheader)
methods.add(self.getblockhash)
methods.add(self.getblock)
methods.add(self.getblockcount)
methods.add(self.getrawtransaction)
methods.add(self.gettxout)
methods.add(self.getpeerinfo)
methods.add(self.sendrawtransaction)
methods.add(self.stop)
methods.add(self.getmempoolinfo)
methods.add(self.getchaintxstats)
methods.add(self.getmininginfo)
methods.add(self.getrawmempool)
methods.add(self.getnetworkinfo)
methods.add(self.uptime)
methods.add(self.getnettotals)
methods.add(self.validateaddress)
methods.add(self.dev_memorysummary, name="dev-gc-stats")
methods.add(self.dev_collect, name="dev-gc-collect")
return await web.TCPSite(runner, host=self.host, port=self.port).start()
runner = web.AppRunner(app)
self.app = app
await runner.setup()
methods.add(self.echo)
methods.add(self.help)
methods.add(self.estimatefee)
methods.add(self.estimatesmartfee)
methods.add(self.getbestblockhash)
methods.add(self.getblockchaininfo)
methods.add(self.getblockheader)
methods.add(self.getblockhash)
methods.add(self.getblock)
methods.add(self.getblockcount)
methods.add(self.getrawtransaction)
methods.add(self.gettxout)
methods.add(self.getpeerinfo)
methods.add(self.sendrawtransaction)
methods.add(self.stop)
methods.add(self.getmempoolinfo)
methods.add(self.getchaintxstats)
methods.add(self.getmininginfo)
methods.add(self.getrawmempool)
methods.add(self.getnetworkinfo)
methods.add(self.uptime)
methods.add(self.getnettotals)
methods.add(self.validateaddress)
methods.add(self.dev_memorysummary, name="dev-gc-stats")
methods.add(self.dev_collect, name="dev-gc-collect")
return await web.TCPSite(runner, host=self.host, port=self.port).start()
async def start(self):
app = web.Application()
app.router.add_post('/', self._handle)
runner = web.AppRunner(app)
self.app = app
await runner.setup()
methods.add(self.echo)
methods.add(self.help)
methods.add(self.estimatefee)
methods.add(self.estimatesmartfee)
methods.add(self.getbestblockhash)
methods.add(self.getblockchaininfo)
methods.add(self.getblockheader)
methods.add(self.getblockhash)
methods.add(self.getblock)
methods.add(self.getblockcount)
methods.add(self.getrawtransaction)
methods.add(self.gettxout)
methods.add(self.getpeerinfo)
methods.add(self.sendrawtransaction)
methods.add(self.stop)
methods.add(self.getmempoolinfo)
methods.add(self.getchaintxstats)
methods.add(self.getmininginfo)
methods.add(self.getrawmempool)
methods.add(self.getnetworkinfo)
methods.add(self.uptime)
methods.add(self.getnettotals)
@methods.add
async def icx_call(**request_params):
Logger.debug(f'json_rpc_server icx_call!', TBEARS_LOG_TAG)
method = 'icx_call'
request = {'method': method, 'params': request_params}
response = await get_icon_inner_task().query(request)
return response_to_json_query(response)
async def start(self):
app = web.Application()
app.router.add_post('/', self._handle)
runner = web.AppRunner(app)
self.app = app
await runner.setup()
methods.add(self.echo)
methods.add(self.help)
methods.add(self.estimatefee)
methods.add(self.estimatesmartfee)
methods.add(self.getbestblockhash)
methods.add(self.getblockchaininfo)
methods.add(self.getblockheader)
methods.add(self.getblockhash)
methods.add(self.getblock)
methods.add(self.getblockcount)
methods.add(self.getrawtransaction)
methods.add(self.gettxout)
methods.add(self.getpeerinfo)
methods.add(self.sendrawtransaction)
methods.add(self.stop)
methods.add(self.getmempoolinfo)
methods.add(self.getchaintxstats)
methods.add(self.getmininginfo)
methods.add(self.getrawmempool)
methods.add(self.getnetworkinfo)
methods.add(self.uptime)
methods.add(self.getnettotals)
methods.add(self.validateaddress)
methods.add(self.help)
methods.add(self.estimatefee)
methods.add(self.estimatesmartfee)
methods.add(self.getbestblockhash)
methods.add(self.getblockchaininfo)
methods.add(self.getblockheader)
methods.add(self.getblockhash)
methods.add(self.getblock)
methods.add(self.getblockcount)
methods.add(self.getrawtransaction)
methods.add(self.gettxout)
methods.add(self.getpeerinfo)
methods.add(self.sendrawtransaction)
methods.add(self.stop)
methods.add(self.getmempoolinfo)
methods.add(self.getchaintxstats)
methods.add(self.getmininginfo)
methods.add(self.getrawmempool)
methods.add(self.getnetworkinfo)
methods.add(self.uptime)
methods.add(self.getnettotals)
methods.add(self.validateaddress)
methods.add(self.dev_memorysummary, name="dev-gc-stats")
methods.add(self.dev_collect, name="dev-gc-collect")
return await web.TCPSite(runner, host=self.host, port=self.port).start()
@methods.add
async def ping():
return 'pong'