Compare commits
2 Commits
master
...
multiaddr-
Author | SHA1 | Date | |
---|---|---|---|
|
6e4d75a6eb | ||
|
2e4de2a412 |
|
@ -42,7 +42,7 @@ class BasicHost(IHost):
|
||||||
"""
|
"""
|
||||||
:return: all the multiaddr addresses this host is listening too
|
:return: all the multiaddr addresses this host is listening too
|
||||||
"""
|
"""
|
||||||
p2p_part = multiaddr.Multiaddr('/ipfs/{}'.format(self.get_id().pretty()))
|
p2p_part = multiaddr.Multiaddr('/p2p/{}'.format(self.get_id().pretty()))
|
||||||
|
|
||||||
addrs = []
|
addrs = []
|
||||||
for transport in self.network.listeners.values():
|
for transport in self.network.listeners.values():
|
||||||
|
|
|
@ -20,11 +20,11 @@ def info_from_p2p_addr(addr):
|
||||||
raise InvalidAddrError()
|
raise InvalidAddrError()
|
||||||
|
|
||||||
ipfspart = parts[-1]
|
ipfspart = parts[-1]
|
||||||
if ipfspart.protocols()[0].code != multiaddr.protocols.P_IPFS:
|
if ipfspart.protocols()[0].code != multiaddr.protocols.P_P2P:
|
||||||
raise InvalidAddrError()
|
raise InvalidAddrError()
|
||||||
|
|
||||||
# make sure the /ipfs value parses as a peer.ID
|
# make sure the /ipfs value parses as a peer.ID
|
||||||
peer_id_str = ipfspart.value_for_protocol(multiaddr.protocols.P_IPFS)
|
peer_id_str = ipfspart.value_for_protocol(multiaddr.protocols.P_P2P)
|
||||||
peer_id = id_b58_decode(peer_id_str)
|
peer_id = id_b58_decode(peer_id_str)
|
||||||
|
|
||||||
# we might have received just an / ipfs part, which means there's no addr.
|
# we might have received just an / ipfs part, which means there's no addr.
|
||||||
|
|
|
@ -6,4 +6,4 @@ pytest-asyncio
|
||||||
click
|
click
|
||||||
base58
|
base58
|
||||||
pymultihash
|
pymultihash
|
||||||
py-multiaddr
|
multiaddr
|
||||||
|
|
|
@ -147,6 +147,6 @@ async def test_host_connect():
|
||||||
assert len(node_a.get_peerstore().peers()) == 1
|
assert len(node_a.get_peerstore().peers()) == 1
|
||||||
|
|
||||||
assert node_b.get_id() in node_a.get_peerstore().peers()
|
assert node_b.get_id() in node_a.get_peerstore().peers()
|
||||||
ma_node_b = multiaddr.Multiaddr('/ipfs/%s' % node_b.get_id().pretty())
|
ma_node_b = multiaddr.Multiaddr('/p2p/%s' % node_b.get_id().pretty())
|
||||||
for addr in node_a.get_peerstore().addrs(node_b.get_id()):
|
for addr in node_a.get_peerstore().addrs(node_b.get_id()):
|
||||||
assert addr.encapsulate(ma_node_b) in node_b.get_addrs()
|
assert addr.encapsulate(ma_node_b) in node_b.get_addrs()
|
||||||
|
|
|
@ -4,7 +4,7 @@ from peer.peerinfo import info_from_p2p_addr
|
||||||
|
|
||||||
def test_info_from_p2p_addr():
|
def test_info_from_p2p_addr():
|
||||||
# pylint: disable=line-too-long
|
# pylint: disable=line-too-long
|
||||||
m_addr = multiaddr.Multiaddr('/ip4/127.0.0.1/tcp/8000/ipfs/3YgLAeMKSAPcGqZkAt8mREqhQXmJT8SN8VCMN4T6ih4GNX9wvK8mWJnWZ1qA2mLdCQ')
|
m_addr = multiaddr.Multiaddr('/ip4/127.0.0.1/tcp/8000/p2p/3YgLAeMKSAPcGqZkAt8mREqhQXmJT8SN8VCMN4T6ih4GNX9wvK8mWJnWZ1qA2mLdCQ')
|
||||||
info = info_from_p2p_addr(m_addr)
|
info = info_from_p2p_addr(m_addr)
|
||||||
assert info.peer_id.pretty() == '3YgLAeMKSAPcGqZkAt8mREqhQXmJT8SN8VCMN4T6ih4GNX9wvK8mWJnWZ1qA2mLdCQ'
|
assert info.peer_id.pretty() == '3YgLAeMKSAPcGqZkAt8mREqhQXmJT8SN8VCMN4T6ih4GNX9wvK8mWJnWZ1qA2mLdCQ'
|
||||||
assert len(info.addrs) == 1
|
assert len(info.addrs) == 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user