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, muxer_opt=muxer_opt, sec_opt=sec_opt,
peerstore_opt=peerstore_opt, disc_opt=disc_opt) peerstore_opt=peerstore_opt, disc_opt=disc_opt)
swarm_opt.add_router(disc_opt)
# TODO enable support for other host type # TODO enable support for other host type
# TODO routing unimplemented # TODO routing unimplemented
host = BasicHost(swarm_opt) host = BasicHost(swarm_opt)

View File

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

View File

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