Ejemplo n.º 1
0
class LongpollThread(threading.Thread):
    def __init__(self, node):
        threading.Thread.__init__(self)
        # query current longpollid
        templat = node.getblocktemplate()
        self.longpollid = templat["longpollid"]
        # create a new connection to the node, we can't use the same
        # connection from two threads
        self.node = AuthServiceProxy(node.url, timeout=600)

    def run(self):
        self.node.getblocktemplate({"longpollid": self.longpollid})
Ejemplo n.º 2
0
def run_allowip_test(tmpdir, allow_ips, rpchost, rpcport):
    '''
    Start a node with rpcwallow IP, and request getinfo
    at a non-localhost IP.
    '''
    base_args = ['-disablewallet', '-nolisten'] + ['-rpcallowip='+x for x in allow_ips]
    nodes = start_nodes(1, tmpdir, [base_args])
    try:
        # connect to node through non-loopback interface
        url = "http://*****:*****@%s:%d" % (rpchost, rpcport,)
        node = AuthServiceProxy(url)
        node.getinfo()
    finally:
        node = None # make sure connection will be garbage collected and closed
        stop_nodes(nodes)
        wait_deuscoinds()
Ejemplo n.º 3
0
def start_node(i, dir, extra_args=None, rpchost=None):
    """
    Start a deuscoind and return RPC connection to it
    """
    datadir = os.path.join(dir, "node"+str(i))
    args = [ "deuscoind", "-datadir="+datadir, "-keypool=1", "-discover=0" ]
    if extra_args is not None: args.extend(extra_args)
    deuscoind_processes[i] = subprocess.Popen(args)
    devnull = open("/dev/null", "w+")
    subprocess.check_call([ "deuscoin-cli", "-datadir="+datadir] +
                          _rpchost_to_args(rpchost)  +
                          ["-rpcwait", "getblockcount"], stdout=devnull)
    devnull.close()
    url = "http://*****:*****@%s:%d" % (rpchost or '127.0.0.1', rpc_port(i))
    proxy = AuthServiceProxy(url)
    proxy.url = url # store URL on proxy for info
    return proxy