Beispiel #1
0
    def loop_connect_to_superpeer(superpeer_ip_queue):
        while 1:
            try:
                pair = yield from superpeer_ip_queue.get()
                if pair is None:
                    break
                peer_name = "%s:%d" % pair
                host, port = pair
                logging.debug("connecting to superpeer at %s", peer_name)
                transport, peer = yield from asyncio.get_event_loop(
                ).create_connection(lambda: BitcoinPeerProtocol(magic_header),
                                    host=host,
                                    port=port)

                logging.debug("connected to superpeer at %s", peer_name)
                yield from initial_handshake(peer, version_data_for_peer(peer))
                logging.debug("handshake complete on %s", peer_name)

                date_address_tuples = yield from get_date_address_tuples(peer)

                logging.debug("got addresses from %s", peer_name)
                for da in date_address_tuples:
                    timestamp_peeraddress_tuple_queue.put_nowait(
                        (-da[0], da[1]))
                logging.debug("closing connection to %s", peer_name)
                transport.close()
            except Exception:
                logging.exception("failed during connect to %s", peer_name)
    def loop_connect_to_superpeer(superpeer_ip_queue):
        while 1:
            try:
                pair = yield from superpeer_ip_queue.get()
                if pair is None:
                    break
                peer_name = "%s:%d" % pair
                host, port = pair
                logging.debug("connecting to superpeer at %s", peer_name)
                transport, peer = yield from asyncio.get_event_loop().create_connection(
                    lambda: BitcoinPeerProtocol(magic_header), host=host, port=port)

                logging.debug("connected to superpeer at %s", peer_name)
                yield from initial_handshake(peer, version_data_for_peer(peer))
                logging.debug("handshake complete on %s", peer_name)

                date_address_tuples = yield from get_date_address_tuples(peer)

                logging.debug("got addresses from %s", peer_name)
                for da in date_address_tuples:
                    timestamp_peeraddress_tuple_queue.put_nowait((-da[0], da[1]))
                logging.debug("closing connection to %s", peer_name)
                transport.close()
            except Exception:
                logging.exception("failed during connect to %s", peer_name)
Beispiel #3
0
 def run_peer2():
     yield from standards.initial_handshake(peer2, VERSION_MSG_2)
     date_address_tuples = yield from standards.get_date_address_tuples(peer2)
     return DA_TUPLES
Beispiel #4
0
 def run_peer2():
     yield from standards.initial_handshake(peer2, VERSION_MSG_2)
     date_address_tuples = yield from standards.get_date_address_tuples(
         peer2)
     return DA_TUPLES