Beispiel #1
0
def get_peers():
    
    config = SimpleConfig()
    
    peers = {}
    
    # 1. get connected interfaces
    
    server = config.get('server')
    
    
    interfaces = get_interfaces([server])
    
    if not interfaces:
        
        print("No connection to", server)
        
        return []
    
    # 2. get list of peers
    
    interface = interfaces[server]
    
    interface.queue_request('server.peers.subscribe', [], 0)
    
    responses = wait_on_interfaces(interfaces).get(server)
    
    if responses:
        
        response = responses[0][1]  # One response, (req, response) tuple
        
        peers = parse_servers(response.get('result'))
        
    return peers
Beispiel #2
0
async def get_peers(network: Network):
    while not network.is_connected():
        await asyncio.sleep(1)
        print("waiting for network to get connected...")
    interface = network.interface
    session = interface.session
    print(f"asking server {interface.server} for its peers")
    peers = parse_servers(await session.send_request('server.peers.subscribe'))
    print(f"got {len(peers)} servers")
    return peers
Beispiel #3
0
async def get_peers(network: Network):
    while not network.is_connected():
        await asyncio.sleep(1)
        print("waiting for network to get connected...")
    interface = network.interface
    session = interface.session
    print(f"asking server {interface.server} for its peers")
    peers = parse_servers(await session.send_request('server.peers.subscribe'))
    print(f"got {len(peers)} servers")
    return peers
Beispiel #4
0
def get_peers():
    # 1. start interface and wait for connection
    interface = electrum.Interface('ecdsa.net:110:s')
    q = Queue.Queue()
    interface.start(q)
    i, r = q.get()
    if not interface.is_connected:
        raise BaseException("not connected")
    # 2. get list of peers
    interface.send_request({'id':0, 'method':'server.peers.subscribe','params':[]})
    i, r = q.get(timeout=10000)
    peers = parse_servers(r.get('result'))
    peers = filter_protocol(peers,'s')
    i.stop()
    return peers
Beispiel #5
0
def get_peers():
    # 1. start interface and wait for connection
    q = Queue.Queue()
    interface = electrum.Interface("ecdsa.net:110:s", q)
    interface.start()
    i, r = q.get()
    if not interface.is_connected():
        raise BaseException("not connected")
    # 2. get list of peers
    interface.send_request({"id": 0, "method": "server.peers.subscribe", "params": []})
    i, r = q.get(timeout=10000)
    peers = parse_servers(r.get("result"))
    peers = filter_protocol(peers, "s")
    i.stop()
    return peers
Beispiel #6
0
def get_peers():
    peers = []
    # 1. get connected interfaces
    server = 'electrumx1.fujicoin.org:50002:s'
    interfaces = get_interfaces([server])
    if not interfaces:
        print "No connection to", server
        return []
    # 2. get list of peers
    interface = interfaces[server]
    interface.queue_request('server.peers.subscribe', [], 0)
    responses = wait_on_interfaces(interfaces).get(server)
    if responses:
        response = responses[0][1]  # One response, (req, response) tuple
        peers = parse_servers(response.get('result'))
        peers = filter_protocol(peers, 's')
    return peers
Beispiel #7
0
def get_peers():
    config = SimpleConfig()
    peers = {}
    # 1. get connected interfaces
    server = config.get('server')
    interfaces = get_interfaces([server])
    if not interfaces:
        print("No connection to", server)
        return []
    # 2. get list of peers
    interface = interfaces[server]
    interface.queue_request('server.peers.subscribe', [], 0)
    responses = wait_on_interfaces(interfaces).get(server)
    if responses:
        response = responses[0][1]  # One response, (req, response) tuple
        peers = parse_servers(response.get('result'))
    return peers
Beispiel #8
0
def get_peers():
    peers = []
    # 1. get connected interfaces
    server = 'ecdsa.net:110:s'
    interfaces = get_interfaces([server])
    if not interfaces:
        print "No connection to", server
        return []
    # 2. get list of peers
    interface = interfaces[server]
    interface.queue_request('server.peers.subscribe', [], 0)
    responses = wait_on_interfaces(interfaces).get(server)
    if responses:
        response = responses[0][1]  # One response, (req, response) tuple
        peers = parse_servers(response.get('result'))
        peers = filter_protocol(peers,'s')
    return peers
Beispiel #9
0
def get_peers():
    # 1. start interface and wait for connection
    q = Queue.Queue()
    interface = electrum.Interface('ecdsa.net:110:s', q)
    interface.start()
    i, r = q.get()
    if not interface.is_connected():
        raise BaseException("not connected")
    # 2. get list of peers
    interface.send_request({
        'id': 0,
        'method': 'server.peers.subscribe',
        'params': []
    })
    i, r = q.get(timeout=10000)
    peers = parse_servers(r.get('result'))
    peers = filter_protocol(peers, 's')
    i.stop()
    return peers
Beispiel #10
0
def get_peers():
    config = SimpleConfig()
    peers = {}
    # 1. get connected interfaces
    server = config.get('server')
    if server is None:
        print(
            "You need to set a secure server, for example (for mainnet): 'electrum setconfig server helicarrier.bauerj.eu:50002:s'"
        )
        return []
    interfaces = get_interfaces([server])
    if not interfaces:
        print("No connection to", server)
        return []
    # 2. get list of peers
    interface = interfaces[server]
    interface.queue_request('server.peers.subscribe', [], 0)
    responses = wait_on_interfaces(interfaces).get(server)
    if responses:
        response = responses[0][1]  # One response, (req, response) tuple
        peers = parse_servers(response.get('result'))
    return peers