requested changes

This commit is contained in:
Alex Haynes 2019-05-05 14:32:41 -04:00
parent 2efc0d3b5c
commit ea4fd8e81f
3 changed files with 4 additions and 8 deletions

View File

@ -109,8 +109,6 @@ async def new_node(
muxer_opt=muxer_opt, sec_opt=sec_opt,
peerstore_opt=peerstore_opt, disc_opt=disc_opt)
swarm_opt.add_router(disc_opt)
# TODO enable support for other host type
# TODO routing unimplemented
host = BasicHost(swarm_opt)

View File

@ -13,8 +13,8 @@ class BasicHost(IHost):
# default options constructor
def __init__(self, network, router=None):
self._network = network
self.peerstore = self._network.peerstore
self._router = router
self.peerstore = self._network.peerstore
def get_id(self):
"""

View File

@ -12,9 +12,9 @@ class KadmeliaPeerRouter(IPeerRouting):
async def find_peer(self, peer_id):
"""
Find specific Peer
FindPeer searches for a peer with given peer_id, returns a peer.PeerInfo
with relevant addresses.
Find a specific peer
:param peer_id: peer to search for
:return: KadPeerInfo of specified peer
"""
# switching peer_id to xor_id used by kademlia as node_id
xor_id = peer_id.get_xor_id()
@ -24,12 +24,10 @@ class KadmeliaPeerRouter(IPeerRouting):
def decode_peerinfo(encoded):
if isinstance(encoded, bytes):
encoded = encoded.decode()
print(encoded)
try:
lines = ast.literal_eval(encoded)
except SyntaxError:
return None
# xor_id = lines[0]
ip = lines[1] # pylint: disable=invalid-name
port = lines[2]
peer_id = lines[3]