prevent attempting to download from oneself

This commit is contained in:
Jack Robison 2019-08-16 16:30:52 -04:00
parent 33945e14d3
commit 5119b71035
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -213,12 +213,13 @@ class Node:
await self.protocol.get_rpc_peer(_peer).ping() await self.protocol.get_rpc_peer(_peer).ping()
result_queue.put_nowait([_peer]) result_queue.put_nowait([_peer])
except asyncio.TimeoutError: except asyncio.TimeoutError:
log.info("blob peer timed out udp")
pass pass
async for results in self.get_iterative_value_finder(binascii.unhexlify(blob_hash.encode())): async for results in self.get_iterative_value_finder(binascii.unhexlify(blob_hash.encode())):
to_put = [] to_put = []
for peer in results: for peer in results:
if peer.address == self.protocol.external_ip and self.protocol.peer_port == peer.tcp_port:
continue
is_good = self.protocol.peer_manager.peer_is_good(peer) is_good = self.protocol.peer_manager.peer_is_good(peer)
if is_good: if is_good:
to_put.append(peer) to_put.append(peer)
@ -231,7 +232,6 @@ class Node:
if not peer.udp_port: if not peer.udp_port:
udp_port_to_try = peer.tcp_port udp_port_to_try = peer.tcp_port
if not peer.udp_port: if not peer.udp_port:
log.info("guess %i for %s:%i", udp_port_to_try, peer.address, peer.tcp_port)
peer.update_udp_port(udp_port_to_try) peer.update_udp_port(udp_port_to_try)
self.loop.create_task(ping(peer)) self.loop.create_task(ping(peer))
else: else: