add peers from shortlist regardless, but check from other nodes
This commit is contained in:
parent
c3d0dd3073
commit
01841694ad
1 changed files with 3 additions and 6 deletions
|
@ -106,7 +106,7 @@ class IterativeFinder:
|
||||||
self.delayed_calls: typing.List[asyncio.Handle] = []
|
self.delayed_calls: typing.List[asyncio.Handle] = []
|
||||||
for peer in get_shortlist(routing_table, key, shortlist):
|
for peer in get_shortlist(routing_table, key, shortlist):
|
||||||
if peer.node_id:
|
if peer.node_id:
|
||||||
self._add_active(peer)
|
self._add_active(peer, force=True)
|
||||||
else:
|
else:
|
||||||
# seed nodes
|
# seed nodes
|
||||||
self._schedule_probe(peer)
|
self._schedule_probe(peer)
|
||||||
|
@ -147,8 +147,8 @@ class IterativeFinder:
|
||||||
def _is_closer(self, peer: 'KademliaPeer') -> bool:
|
def _is_closer(self, peer: 'KademliaPeer') -> bool:
|
||||||
return not self.closest_peer or self.distance.is_closer(peer.node_id, self.closest_peer.node_id)
|
return not self.closest_peer or self.distance.is_closer(peer.node_id, self.closest_peer.node_id)
|
||||||
|
|
||||||
def _add_active(self, peer):
|
def _add_active(self, peer, force=False):
|
||||||
if self.peer_manager.peer_is_good(peer) is False:
|
if not force and self.peer_manager.peer_is_good(peer) is False:
|
||||||
return
|
return
|
||||||
if self.closest_peer and self.peer_manager.peer_is_good(self.closest_peer) is False:
|
if self.closest_peer and self.peer_manager.peer_is_good(self.closest_peer) is False:
|
||||||
log.debug("[%s] closest peer went bad", self.key.hex()[:8])
|
log.debug("[%s] closest peer went bad", self.key.hex()[:8])
|
||||||
|
@ -211,9 +211,6 @@ class IterativeFinder:
|
||||||
continue
|
continue
|
||||||
if origin_address == (self.protocol.external_ip, self.protocol.udp_port):
|
if origin_address == (self.protocol.external_ip, self.protocol.udp_port):
|
||||||
continue
|
continue
|
||||||
if self.peer_manager.peer_is_good(peer) is False:
|
|
||||||
self.active.discard(peer)
|
|
||||||
continue
|
|
||||||
self._schedule_probe(peer)
|
self._schedule_probe(peer)
|
||||||
added += 1
|
added += 1
|
||||||
log.debug("running %d probes for key %s", len(self.running_probes), self.key.hex()[:8])
|
log.debug("running %d probes for key %s", len(self.running_probes), self.key.hex()[:8])
|
||||||
|
|
Loading…
Add table
Reference in a new issue