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
|
||||
|
||||
|
@ -10,9 +10,9 @@ class PeerInfo:
|
|||
peer_id: ID
|
||||
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.addrs = addrs
|
||||
self.addrs = list(addrs)
|
||||
|
||||
|
||||
def info_from_p2p_addr(addr: multiaddr.Multiaddr) -> PeerInfo:
|
||||
|
|
|
@ -116,9 +116,9 @@ class GossipSub(IPubsubRouter):
|
|||
self.peers_floodsub.append(peer_id)
|
||||
else:
|
||||
# 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,
|
||||
# what we check above. In this case, probably we registered gossipsub to a wrong
|
||||
# `protocol_id` in multistream-select, or wrong versions.
|
||||
# instance in multistream-select, but it is not the protocol that gossipsub supports.
|
||||
# In this case, probably we registered gossipsub to a wrong `protocol_id`
|
||||
# in multistream-select, or wrong versions.
|
||||
# TODO: Better handling
|
||||
raise Exception(f"protocol is not supported: protocol_id={protocol_id}")
|
||||
|
||||
|
|
|
@ -183,6 +183,7 @@ async def make_p2pd(
|
|||
for maddr in maddrs:
|
||||
try:
|
||||
ip = maddr.value_for_protocol(multiaddr.protocols.P_IP4)
|
||||
# NOTE: Check if this `maddr` uses `tcp`.
|
||||
maddr.value_for_protocol(multiaddr.protocols.P_TCP)
|
||||
except multiaddr.exceptions.ProtocolLookupError:
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue
Block a user