PR feedback

- Use `TMuxerOptions` and `TSecurityOptions` in libp2p/__init__.py
- Remove the default value for `muxer_transports_by_protocol` in
`MuxerMultistream` and `secure_transports_by_protocol`
`SecureMultistream`
This commit is contained in:
mhchia 2019-09-24 12:51:59 +08:00
parent 1bd18c84f2
commit 37bee9fb16
No known key found for this signature in database
GPG Key ID: 389EFBEA1362589A
3 changed files with 8 additions and 11 deletions

View File

@ -1,5 +1,5 @@
import asyncio import asyncio
from typing import Mapping, Sequence from typing import Sequence
from libp2p.crypto.keys import KeyPair from libp2p.crypto.keys import KeyPair
from libp2p.crypto.rsa import create_new_key_pair from libp2p.crypto.rsa import create_new_key_pair
@ -15,10 +15,9 @@ from libp2p.routing.interfaces import IPeerRouting
from libp2p.routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter from libp2p.routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter
from libp2p.security.insecure.transport import PLAINTEXT_PROTOCOL_ID, InsecureTransport from libp2p.security.insecure.transport import PLAINTEXT_PROTOCOL_ID, InsecureTransport
import libp2p.security.secio.transport as secio import libp2p.security.secio.transport as secio
from libp2p.security.secure_transport_interface import ISecureTransport
from libp2p.stream_muxer.mplex.mplex import MPLEX_PROTOCOL_ID, Mplex from libp2p.stream_muxer.mplex.mplex import MPLEX_PROTOCOL_ID, Mplex
from libp2p.transport.tcp.tcp import TCP from libp2p.transport.tcp.tcp import TCP
from libp2p.transport.typing import TMuxerClass, TMuxerOptions, TSecurityOptions from libp2p.transport.typing import TMuxerOptions, TSecurityOptions
from libp2p.transport.upgrader import TransportUpgrader from libp2p.transport.upgrader import TransportUpgrader
from libp2p.typing import TProtocol from libp2p.typing import TProtocol

View File

@ -31,12 +31,11 @@ class SecurityMultistream(ABC):
multiselect: Multiselect multiselect: Multiselect
multiselect_client: MultiselectClient multiselect_client: MultiselectClient
def __init__(self, secure_transports_by_protocol: TSecurityOptions = None) -> None: def __init__(self, secure_transports_by_protocol: TSecurityOptions) -> None:
self.transports = OrderedDict() self.transports = OrderedDict()
self.multiselect = Multiselect() self.multiselect = Multiselect()
self.multiselect_client = MultiselectClient() self.multiselect_client = MultiselectClient()
if secure_transports_by_protocol is not None:
for protocol, transport in secure_transports_by_protocol.items(): for protocol, transport in secure_transports_by_protocol.items():
self.add_transport(protocol, transport) self.add_transport(protocol, transport)

View File

@ -26,11 +26,10 @@ class MuxerMultistream:
multiselect: Multiselect multiselect: Multiselect
multiselect_client: MultiselectClient multiselect_client: MultiselectClient
def __init__(self, muxer_transports_by_protocol: TMuxerOptions = None) -> None: def __init__(self, muxer_transports_by_protocol: TMuxerOptions) -> None:
self.transports = OrderedDict() self.transports = OrderedDict()
self.multiselect = Multiselect() self.multiselect = Multiselect()
self.multiselect_client = MultiselectClient() self.multiselect_client = MultiselectClient()
if muxer_transports_by_protocol is not None:
for protocol, transport in muxer_transports_by_protocol.items(): for protocol, transport in muxer_transports_by_protocol.items():
self.add_transport(protocol, transport) self.add_transport(protocol, transport)