Beispiel #1
0
def go (G):
    global in_flight
    addr0 = ('127.0.0.1', 0)
    addr1 = parse_addr_arg (G.args.connect)
    cp = ChainPuller (G, addr0, addr1)
    cp.wait_for ('verack')
    if G.args.getblocks:
        W ('downloading block names...\n')
        names = cp.getblocks()
    else:
        W ('downloading headers...\n')
        names = cp.getheaders()
    start = time.time()
    W ('got %d names...\n' % (len(names),))
    WB ('[BLOCKNUM] ')
    WR ('(MB/s)\n')
    for i in range (0, len (names), 50):
        chunk = names[i:i+50]
        cp.getdata ([(OBJ_BLOCK, name) for name in chunk])
        in_flight += len(chunk)
        in_flight_cv.wait()
    # let it finish
    while 1:
        coro.sleep_relative (1)
        if in_flight == 0:
            break
    stop = time.time()
    WB (
        '\ntransferred %.2f GB in %d secs (%.2f MB/s)\n' % (
            float(total_bytes) / GB,
            stop - start,
            (float(total_bytes) / MB) / (stop - start)
        )
    )
    coro.set_exit()
Beispiel #2
0
def serve(addr):
    addr0 = parse_addr_arg(addr)
    if ':' in addr0[0]:
        ipv6_server_addrs.append(addr0)
        s = coro.tcp6_sock()
    else:
        ipv4_server_addrs.append(addr0)
        s = coro.tcp_sock()
    s.bind(addr0)
    s.listen(100)
    LOG('starting', addr0)
    while 1:
        conn, addr1 = s.accept()
        G.in_conn_sem.acquire(1)
        Connection(addr0, addr1, sock=conn)
Beispiel #3
0
def serve (addr):
    addr0 = parse_addr_arg (addr)
    if ':' in addr0[0]:
        ipv6_server_addrs.append (addr0)
        s = coro.tcp6_sock()
    else:
        ipv4_server_addrs.append (addr0)
        s = coro.tcp_sock()
    s.bind (addr0)
    s.listen (100)
    LOG ('starting', addr0)
    while 1:
        conn, addr1 = s.accept()
        G.in_conn_sem.acquire (1)
        Connection (addr0, addr1, sock=conn)
Beispiel #4
0
def connect(addr):
    addr1 = parse_addr_arg(addr)
    G.out_conn_sem.acquire(1)
    addr0 = get_my_addr(addr1)
    Connection(addr0, addr1)
Beispiel #5
0
def connect (addr):
    addr1 = parse_addr_arg (addr)
    G.out_conn_sem.acquire (1)
    addr0 = get_my_addr (addr1)
    Connection (addr0, addr1)
Beispiel #6
0
def connect (G, addr):
    addr0 = ('127.0.0.1', 0)
    addr1 = parse_addr_arg (addr)
    BlockWatcher (G, addr0, addr1)
    W ('connect() called\n')