From f0b49fc153da0d1f4d8fb1c6383f721c5648fd6b Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Mon, 4 Feb 2019 13:33:06 -0500 Subject: [PATCH] always return close peers from findValue --- lbrynet/dht/protocol/protocol.py | 3 +-- tests/unit/dht/protocol/test_protocol.py | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lbrynet/dht/protocol/protocol.py b/lbrynet/dht/protocol/protocol.py index c74a6e98c..0b31bc1b5 100644 --- a/lbrynet/dht/protocol/protocol.py +++ b/lbrynet/dht/protocol/protocol.py @@ -77,6 +77,7 @@ class KademliaRPC: response = { b'token': self.make_token(rpc_contact.compact_ip()), + b'contacts': self.find_node(rpc_contact, key) } if self.protocol.protocol_version: @@ -93,8 +94,6 @@ class KademliaRPC: peers.append(self.compact_address()) if peers: response[key] = peers - else: - response[b'contacts'] = self.find_node(rpc_contact, key) return response def refresh_token(self): # TODO: this needs to be called periodically diff --git a/tests/unit/dht/protocol/test_protocol.py b/tests/unit/dht/protocol/test_protocol.py index bd46f3c12..8a19dce74 100644 --- a/tests/unit/dht/protocol/test_protocol.py +++ b/tests/unit/dht/protocol/test_protocol.py @@ -81,8 +81,9 @@ class TestProtocol(AsyncioTestCase): self.assertListEqual([peer2_from_peer1], peer1.data_store.get_storing_contacts()) peer1.data_store.completed_blobs.add(binascii.hexlify(b'2' * 48).decode()) find_value_response = peer1.node_rpc.find_value(peer3, b'2' * 48) + self.assertEqual(len(find_value_response[b'contacts']), 0) self.assertSetEqual( - {b'2' * 48, b'token', b'protocolVersion'}, set(find_value_response.keys()) + {b'2' * 48, b'token', b'protocolVersion', b'contacts'}, set(find_value_response.keys()) ) self.assertEqual(2, len(find_value_response[b'2' * 48])) self.assertEqual(find_value_response[b'2' * 48][0], peer2_from_peer1.compact_address_tcp())