def execute_mining(path='mining', *, count, host='http://localhost', port=8085, data=None, prefix=settings.API_VERSION_PREFIX): """Execute a mining on a given server""" from hathor.cli.mining import create_parser, execute partial_url = '{}:{}/{}/'.format(host, port, prefix) url = urllib.parse.urljoin(partial_url, path) parser = create_parser() args = parser.parse_args([url, '--count', str(count)]) execute(args)
def execute_tx_gen(*, count, address=None, value=None, timestamp=None, host='http://localhost', port=8085, data=None, prefix=settings.API_VERSION_PREFIX): """Execute a tx generator on a given server""" from hathor.cli.tx_generator import create_parser, execute url = '{}:{}/{}/'.format(host, port, prefix) parser = create_parser() argv = [url, '--count', str(count)] if address is not None: argv.extend(['--address', address]) if value is not None: argv.extend(['--value', str(value)]) if timestamp is not None: argv.extend(['--timestamp', timestamp]) args = parser.parse_args(argv) execute(args)