PR feedback
- Use `Sequence` instead of `List` - Add note - Remove redundant words in docstring
This commit is contained in:
parent
db0da8083a
commit
0e3d4508d6
|
@ -1,4 +1,4 @@
|
||||||
from typing import List
|
from typing import List, Sequence
|
||||||
|
|
||||||
import multiaddr
|
import multiaddr
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ class PeerInfo:
|
||||||
peer_id: ID
|
peer_id: ID
|
||||||
addrs: List[multiaddr.Multiaddr]
|
addrs: List[multiaddr.Multiaddr]
|
||||||
|
|
||||||
def __init__(self, peer_id: ID, addrs: List[multiaddr.Multiaddr]) -> None:
|
def __init__(self, peer_id: ID, addrs: Sequence[multiaddr.Multiaddr]) -> None:
|
||||||
self.peer_id = peer_id
|
self.peer_id = peer_id
|
||||||
self.addrs = addrs
|
self.addrs = list(addrs)
|
||||||
|
|
||||||
|
|
||||||
def info_from_p2p_addr(addr: multiaddr.Multiaddr) -> PeerInfo:
|
def info_from_p2p_addr(addr: multiaddr.Multiaddr) -> PeerInfo:
|
||||||
|
|
|
@ -116,9 +116,9 @@ class GossipSub(IPubsubRouter):
|
||||||
self.peers_floodsub.append(peer_id)
|
self.peers_floodsub.append(peer_id)
|
||||||
else:
|
else:
|
||||||
# We should never enter here. Becuase the `protocol_id` is registered by your pubsub
|
# We should never enter here. Becuase the `protocol_id` is registered by your pubsub
|
||||||
# instance in multistream-select, but it is not the protocol that gossipsub supports,
|
# instance in multistream-select, but it is not the protocol that gossipsub supports.
|
||||||
# what we check above. In this case, probably we registered gossipsub to a wrong
|
# In this case, probably we registered gossipsub to a wrong `protocol_id`
|
||||||
# `protocol_id` in multistream-select, or wrong versions.
|
# in multistream-select, or wrong versions.
|
||||||
# TODO: Better handling
|
# TODO: Better handling
|
||||||
raise Exception(f"protocol is not supported: protocol_id={protocol_id}")
|
raise Exception(f"protocol is not supported: protocol_id={protocol_id}")
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,7 @@ async def make_p2pd(
|
||||||
for maddr in maddrs:
|
for maddr in maddrs:
|
||||||
try:
|
try:
|
||||||
ip = maddr.value_for_protocol(multiaddr.protocols.P_IP4)
|
ip = maddr.value_for_protocol(multiaddr.protocols.P_IP4)
|
||||||
|
# NOTE: Check if this `maddr` uses `tcp`.
|
||||||
maddr.value_for_protocol(multiaddr.protocols.P_TCP)
|
maddr.value_for_protocol(multiaddr.protocols.P_TCP)
|
||||||
except multiaddr.exceptions.ProtocolLookupError:
|
except multiaddr.exceptions.ProtocolLookupError:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue
Block a user