mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-11 15:40:54 +00:00
added none type to return value of negotiate and changed caller handles to handle none. Added newsfragment.
This commit is contained in:
@ -26,6 +26,9 @@ from libp2p.protocol_muxer.multiselect_client import (
|
||||
from libp2p.protocol_muxer.multiselect_communicator import (
|
||||
MultiselectCommunicator,
|
||||
)
|
||||
from libp2p.transport.exceptions import (
|
||||
SecurityUpgradeFailure,
|
||||
)
|
||||
|
||||
"""
|
||||
Represents a secured connection object, which includes a connection and details about
|
||||
@ -104,7 +107,7 @@ class SecurityMultistream(ABC):
|
||||
:param is_initiator: true if we are the initiator, false otherwise
|
||||
:return: selected secure transport
|
||||
"""
|
||||
protocol: TProtocol
|
||||
protocol: TProtocol | None
|
||||
communicator = MultiselectCommunicator(conn)
|
||||
if is_initiator:
|
||||
# Select protocol if initiator
|
||||
@ -114,5 +117,7 @@ class SecurityMultistream(ABC):
|
||||
else:
|
||||
# Select protocol if non-initiator
|
||||
protocol, _ = await self.multiselect.negotiate(communicator)
|
||||
if protocol is None:
|
||||
raise SecurityUpgradeFailure("No protocol selected")
|
||||
# Return transport from protocol
|
||||
return self.transports[protocol]
|
||||
|
||||
Reference in New Issue
Block a user