async def ledger_sim_proxy(): """ Return an async proxy to the ledger sim instance running on 9868. """ from chiasim.clients import ledger_sim from chiasim.remote.client import request_response_proxy reader, writer = await asyncio.open_connection(host="localhost", port=9868) proxy = request_response_proxy(reader, writer, ledger_sim.REMOTE_SIGNATURES) return proxy
def main(args=sys.argv): parser = argparse.ArgumentParser(description="Chia client.") parser.add_argument("-p", "--port", help="remote port", default=9868) parser.add_argument("host", help="remote host") parser.add_argument("function", help="function") parser.add_argument("arguments", help="arguments (as json)", type=json.loads) args = parser.parse_args(args=args[1:]) init_logging() run = asyncio.get_event_loop().run_until_complete reader, writer = run(asyncio.open_connection(args.host, args.port)) ledger_api = request_response_proxy(reader, writer) r = run(getattr(ledger_api, args.function)(**args.arguments)) print(r)
async def proxy_for_unix_connection(path): reader, writer = await asyncio.open_unix_connection(path) return request_response_proxy(reader, writer, ledger_sim.REMOTE_SIGNATURES)
async def connect_to_ledger_sim(host="localhost", port=9868): reader, writer = await asyncio.open_connection(host, port) return request_response_proxy(reader, writer, REMOTE_SIGNATURES)
async def proxy_for_unix_connection(path): reader, writer = await asyncio.open_unix_connection(str(path)) return request_response_proxy(reader, writer)