Beispiel #1
0
 def _find_random_node(self):
     if _Debug:
         lg.out(_DebugLevel + 10, 'stun_client._find_random_node')
     new_key = dht_service.random_key()
     d = dht_service.find_node(new_key)
     d.addCallback(self._some_nodes_found)
     d.addErrback(self._nodes_not_found)
Beispiel #2
0
 def _find_random_node(self):
     if _Debug:
         lg.out(_DebugLevel + 10, 'stun_client._find_random_node')
     new_key = dht_service.random_key()
     d = dht_service.find_node(new_key)
     d.addCallback(self._some_nodes_found)
     d.addErrback(self._nodes_not_found)
Beispiel #3
0
def lookup_in_dht():
    """
    Pick random node from Distributed Hash Table.
    Generates
    """
    if _Debug:
        lg.out(_DebugLevel, 'lookup.lookup_in_dht')
    return dht_service.find_node(dht_service.random_key())
 def _find_random_node(self):
     if _Debug:
         lg.out(_DebugLevel, 'proxy_receiver._find_random_node')
     # DEBUG
     self._got_remote_idurl({'idurl': 'http://veselin-p2p.ru/bitdust_j_vps1001.xml'})
     return
     new_key = dht_service.random_key()
     d = dht_service.find_node(new_key)
     d.addCallback(self._some_nodes_found)
     d.addErrback(lambda x: self.automat('nodes-not-found'))
     return d
Beispiel #5
0
def lookup_in_dht(layer_id=0):
    """
    Pick random node from Distributed Hash Table.
    Generates
    """
    if _Debug:
        lg.out(_DebugLevel, 'lookup.lookup_in_dht layer_id=%d' % (layer_id, ))
    d = dht_service.find_node(dht_service.random_key(), layer_id=layer_id)
    if _Debug:
        d.addErrback(lg.errback,
                     debug=_Debug,
                     debug_level=_DebugLevel,
                     method='lookup_in_dht')
    return d
Beispiel #6
0
 def _find_random_nodes(self, tries, result_list, prev_key=None):
     if prev_key and prev_key in self.deferreds:
         self.deferreds.pop(prev_key)
     if _Debug:
         lg.out(_DebugLevel + 10, 'stun_client._find_random_nodes tries=%d result_list=%d' % (tries, len(result_list)))
     if tries <= 0 or len(result_list) >= self.minimum_needed_servers:
         if len(result_list) > 0:
             self.automat('found-some-nodes', result_list)
         else:
             self.automat('dht-nodes-not-found')
         return
     new_key = dht_service.random_key()
     d = dht_service.find_node(new_key)
     d.addCallback(lambda nodes: self._find_random_nodes(tries - 1, list(set(result_list + nodes)), new_key))
     d.addErrback(lambda x: self._find_random_nodes(tries - 1, result_list, new_key))
     self.deferreds[new_key] = d
Beispiel #7
0
 def _find_random_nodes(self, tries, result_list, prev_key=None):
     if prev_key and prev_key in self.deferreds:
         self.deferreds.pop(prev_key)
     if _Debug:
         lg.out(_DebugLevel + 10, 'stun_client._find_random_nodes tries=%d result_list=%d' % (tries, len(result_list)))
     if tries <= 0 or len(result_list) >= self.minimum_needed_servers:
         if len(result_list) > 0:
             self.automat('found-some-nodes', result_list)
         else:
             self.automat('dht-nodes-not-found')
         return
     new_key = dht_service.random_key()
     d = dht_service.find_node(new_key)
     d.addCallback(lambda nodes: self._find_random_nodes(tries - 1, list(set(result_list + nodes)), new_key))
     d.addErrback(lambda x: self._find_random_nodes(tries - 1, result_list, new_key))
     self.deferreds[new_key] = d
 def lookup_in_dht(self, **kwargs):
     from dht import dht_service
     return dht_service.find_node(dht_service.random_key())
 def _lookup_in_dht(self, **kwargs):
     from dht import dht_service
     from logs import lg
     lg.out(12, 'service_nodes_lookup._lookup_in_dht')
     return dht_service.find_node(dht_service.random_key())