Fetches the peers from the validator.
        Request:

        Response:
            data: JSON array of peer endpoints
            link: The link to this exact query
497151
async def fetch_peers(self, request):
        

        response = await self._query_validator(
            Message.CLIENT_PEERS_GET_REQUEST,
            client_peers_pb2.ClientPeersGetResponse,
            client_peers_pb2.ClientPeersGetRequest())

        return self._wrap_response(
            request,
            data=response['peers'],
            metadata=self._get_metadata(request, response))
137595
def getPeer(self, url):
        
        peers = list(models.Peer.select().where(models.Peer.url == url))
        if len(peers) == 0:
            raise exceptions.PeerNotFoundException(url)
        return peers[0]
781027
def peers(self):
        

        resp = self.call('peers')

        result = {}
        peers = resp.get('peers') or {}

        for host, version in peers.items():
            result[host] = int(version)

        return result
1014499
async def _nodes_found(self, responses):
        
        toremove = []
        for peerid, response in responses.items():
            response = RPCFindResponse(response)
            if not response.happened():
                toremove.append(peerid)
            else:
                self.nearest.push(response.get_node_list())
        self.nearest.remove(toremove)

        if self.nearest.have_contacted_all():
            return list(self.nearest)
        return await self.find()
218280
private ImmutableList<EndPoint> getEndPoints() {
        ImmutableList<EndPoint> endPoints = _endPoints;
        if (endPoints == null) {
            boolean locked = false;
            try {
                long timeout = System.currentTimeMillis() + 10;

                locked = _lock.tryLock(10, TimeUnit.MILLISECONDS);
                if (locked) {
                    endPoints = _endPoints;
                    long waitTime = timeout - System.currentTimeMillis();
                    if (endPoints == null && waitTime > 0) {
                        _endpointsAvailable.await(waitTime, TimeUnit.MILLISECONDS);
                        endPoints = _endPoints;
                    }
                }
            } catch (InterruptedException e) {
                // ignore
            } finally {
                if (locked) {
                    _lock.unlock();
                }
            }

            if (endPoints == null) {
                // Took too long waiting for the background to re-populate endpoints, just fetch from the source
                endPoints = getEndPointsFromHostDiscovery();
            }
        }
        
        return endPoints;
    }
1267232
def getEndpointSubscriptions(self,ep):
		'''
		
		'''
		result = asyncResult()
		result.endpoint = ep
		data = self._getURL("/subscriptions/"+ep)
		if data.status_code == 200: #immediate success
			result.error = False
			result.is_done = True
			result.result = data.content
		else:
			result.error = response_codes("unsubscribe",data.status_code)
			result.is_done = True
		result.raw_data = data.content
		result.status_code = data.status_code
		return result
1268298
def get_peers_public_keys(self):
        """"""
        with self._lock:
            # Use a generator inside the list comprehension to filter out None
            # values in a single pass
            return [key for key
                    in (self._network.connection_id_to_public_key(peer)
                        for peer
                        in copy.copy(self._peers))
                    if key is not None]
249929
def get_atlas_peers(hostport, timeout=30, my_hostport=None, proxy=None):
    
    assert hostport or proxy, 'need either hostport or proxy'

    peers_schema = {
        'type': 'object',
        'properties': {
            'peers': {
                'type': 'array',
                'items': {
                    'type': 'string',
                    'pattern': '^([^:]+):([1-9][0-9]{1,4})$',
                },
            },
        },
        'required': [
            'peers'
        ],
    }

    schema = json_response_schema( peers_schema )

    if proxy is None:
        proxy = connect_hostport(hostport)

    peers = None
    try:
        peer_list_resp = proxy.get_atlas_peers()
        peer_list_resp = json_validate(schema, peer_list_resp)
        if json_is_error(peer_list_resp):
            return peer_list_resp

        # verify that all strings are host:ports
        for peer_hostport in peer_list_resp['peers']:
            peer_host, peer_port = url_to_host_port(peer_hostport)
            if peer_host is None or peer_port is None:
                return {'error': 'Server did not return valid Atlas peers', 'http_status': 503}

        peers = peer_list_resp

    except ValidationError as ve:
        if BLOCKSTACK_DEBUG:
            log.exception(ve)

        resp = {'error': 'Server response did not match expected schema.  You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
        return resp

    except socket.timeout:
        log.error("Connection timed out")
        resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
        return resp

    except socket.error as se:
        log.error("Connection error {}".format(se.errno))
        resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
        return resp

    except Exception as ee:
        if BLOCKSTACK_DEBUG:
            log.exception(ee)

        log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
        resp = {'error': 'Failed to contact Blockstack node {}.  Try again with `--debug`.'.format(hostport), 'http_status': 500}
        return resp

    return peers
1222515
function sumOnLinePeers() {
	let nowTime = Date.now();
	assocOnlinePeers = {};
	Object.keys(assocAllOutBoundPeers).forEach(function(curUrl){    
		var curPeers = assocAllOutBoundPeers[curUrl];   
		if(nowTime - parseInt(curPeers.time) < 3 * 60 * 1000){
			for (var j=0; j<curPeers.peers.length; j++){
                if(assocOnlinePeers[curPeers.peers[j]]) 
					assocOnlinePeers[curPeers.peers[j]]++;
				else
					assocOnlinePeers[curPeers.peers[j]] = 1;
            }
		}       
    }); 
}
239747
def _resolve(self):
        
        endpoints = {}
        r = self.resolver.query(self.service, 'SRV')
        for rec in r.response.additional:
            name = rec.name.to_text()
            addr = rec.items[0].address
            endpoints[name] = {'addr': addr}
        for rec in r.response.answer[0].items:
            name = '.'.join(rec.target.labels)
            endpoints[name]['port'] = rec.port
        return [
            'http://{ip}:{port}'.format(
                ip=v['addr'], port=v['port']
            ) for v in endpoints.values()
        ]
802771
def get_all(self):
        
        self.optional_params = {}
        self.endpoints = self._ENDPOINTS[:10]
        json_data = self.fetch(fmt_p=no_pandas)
        self.endpoints = self._ENDPOINTS[10:20]
        json_data_2 = self.fetch(fmt_p=no_pandas)
        for symbol in self.symbols:
            if symbol not in json_data:
                raise IEXSymbolError(symbol)
            json_data[symbol].update(json_data_2[symbol])
        return json_data[self.symbols[0]] if self.n_symbols == 1 else json_data
747922
def get_endpoints(url_base, tenant_id, user, password):
    
    url = 'http://' + url_base + '/v2.0/tokens'
    headers = {'Content-Type': 'application/json'}
    payload = {'auth': {'tenantId': '' + tenant_id + '',
                        'passwordCredentials': {'username':
                        '' + user + '', 'password': '' +
                        password + ''}}}
    try:
        response = requests.post(url, headers=headers,
                                 data=json.dumps(payload))
        response_json = response.json()
        services = response_json['access']['serviceCatalog']
    except Exception as e:
        raise Exception('Error to obtain a image ' + e.message)

    endpoints = {}
    for service in services:
        service_endpoints = {}
        for endpoint in service['endpoints']:
            service_endpoints.update({endpoint['region']:
                                      endpoint['publicURL']})
        endpoints.update({service['type']: service_endpoints})
    return endpoints
1059817
def _get_datapoints(self, params):
        
        url = self.query_uri + '/v1/datapoints'
        return self.service._get(url, params=params)
1038098
async def _query_validator(self, request_type, response_proto,
                               payload, error_traps=None):
        
        LOGGER.debug(
            'Sending %s request to validator',
            self._get_type_name(request_type))

        payload_bytes = payload.SerializeToString()
        response = await self._send_request(request_type, payload_bytes)
        content = self._parse_response(response_proto, response)

        LOGGER.debug(
            'Received %s response from validator with status %s',
            self._get_type_name(response.message_type),
            self._get_status_name(response_proto, content.status))

        self._check_status_errors(response_proto, content, error_traps)
        return self._message_to_dict(content)
1116210
def get_match(self, match_id):
        """"""
        return self._make_req(endpoints.MATCH, dict(
            k=self.key,
            mp=match_id), Match)
919852
def fetchall(self):
        
        result = r = self.fetchmany(size=self.FETCHALL_BLOCKSIZE)
        while len(r) == self.FETCHALL_BLOCKSIZE or not self._received_last_resultset_part:
            r = self.fetchmany(size=self.FETCHALL_BLOCKSIZE)
            result.extend(r)
        return result
691739
def query_multiple_endpoints(urls, query: PyQuery):
    
    urls = list(urls)
    return _query_multiple_endpoints(urls, query)