From 0e3d4508d6b766d6691634649b44da3574968dee Mon Sep 17 00:00:00 2001 From: mhchia Date: Wed, 4 Sep 2019 20:49:14 +0800 Subject: [PATCH] PR feedback - Use `Sequence` instead of `List` - Add note - Remove redundant words in docstring --- libp2p/peer/peerinfo.py | 6 +++--- libp2p/pubsub/gossipsub.py | 6 +++--- tests/interop/daemon.py | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libp2p/peer/peerinfo.py b/libp2p/peer/peerinfo.py index 2f41a6c..069a67d 100644 --- a/libp2p/peer/peerinfo.py +++ b/libp2p/peer/peerinfo.py @@ -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: diff --git a/libp2p/pubsub/gossipsub.py b/libp2p/pubsub/gossipsub.py index f2b4521..267bb81 100644 --- a/libp2p/pubsub/gossipsub.py +++ b/libp2p/pubsub/gossipsub.py @@ -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}") diff --git a/tests/interop/daemon.py b/tests/interop/daemon.py index 754b563..e9c07e8 100644 --- a/tests/interop/daemon.py +++ b/tests/interop/daemon.py @@ -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