mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Fix linting issues'
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import asyncio
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from abc import ABC
|
||||
from libp2p.protocol_muxer.multiselect_client import MultiselectClient
|
||||
from libp2p.protocol_muxer.multiselect import Multiselect
|
||||
|
||||
# pylint: disable=W0105
|
||||
|
||||
"""
|
||||
Represents a secured connection object, which includes a connection and details about the security
|
||||
involved in the secured connection
|
||||
@ -13,7 +13,7 @@ Relevant go repo: https://github.com/libp2p/go-conn-security/blob/master/interfa
|
||||
class SecurityMultistream(ABC):
|
||||
|
||||
def __init__(self):
|
||||
# Map protocol to secure transport
|
||||
# Map protocol to secure transport
|
||||
self.transports = {}
|
||||
|
||||
# Create multiselect
|
||||
@ -31,7 +31,7 @@ class SecurityMultistream(ABC):
|
||||
# we only care about selecting the protocol, not any handler function
|
||||
self.multiselect.add_handler(protocol, None)
|
||||
|
||||
|
||||
|
||||
async def secure_inbound(self, conn):
|
||||
"""
|
||||
Secure the connection, either locally or by communicating with opposing node via conn,
|
||||
@ -66,19 +66,21 @@ class SecurityMultistream(ABC):
|
||||
|
||||
async def select_transport(self, conn, initiator):
|
||||
"""
|
||||
Select a transport that both us and the node on the
|
||||
Select a transport that both us and the node on the
|
||||
other end of conn support and agree on
|
||||
:param conn: conn to choose a transport over
|
||||
:param initiator: true if we are the initiator, false otherwise
|
||||
:return: selected secure transport
|
||||
"""
|
||||
# TODO: Is conn acceptable to multiselect/multiselect_client instead of stream? In go repo,
|
||||
# they pass in a raw conn (https://raw.githubusercontent.com/libp2p/go-conn-security-multistream/master/ssms.go)
|
||||
|
||||
# TODO: Is conn acceptable to multiselect/multiselect_client
|
||||
# instead of stream? In go repo, they pass in a raw conn
|
||||
# (https://raw.githubusercontent.com/libp2p/go-conn-security-multistream/master/ssms.go)
|
||||
|
||||
protocol = None
|
||||
if initiator:
|
||||
# Select protocol if initiator
|
||||
protocol = await self.multiselect_client.select_one_of(list(self.transports.keys()), conn)
|
||||
protocol = \
|
||||
await self.multiselect_client.select_one_of(list(self.transports.keys()), conn)
|
||||
else:
|
||||
# Select protocol if non-initiator
|
||||
protocol, _ = await self.multiselect.negotiate(conn)
|
||||
|
||||
Reference in New Issue
Block a user