Update IMultiselectClient

This commit is contained in:
NIC619 2019-09-14 22:24:53 +08:00
parent 9bad7a61f0
commit 501513b747
No known key found for this signature in database
GPG Key ID: 570C35F5C2D51B17

View File

@ -13,16 +13,12 @@ class IMultiselectClient(ABC):
module in order to select a protocol id to communicate over module in order to select a protocol id to communicate over
""" """
@abstractmethod async def handshake(self, communicator: IMultiselectCommunicator) -> None:
async def select_protocol_or_fail(
self, protocol: TProtocol, communicator: IMultiselectCommunicator
) -> TProtocol:
""" """
Send message to multiselect selecting protocol Ensure that the client and multiselect
and fail if multiselect does not return same protocol are both using the same multiselect protocol
:param protocol: protocol to select
:param stream: stream to communicate with multiselect over :param stream: stream to communicate with multiselect over
:return: selected protocol :raise Exception: multiselect protocol ID mismatch
""" """
@abstractmethod @abstractmethod
@ -37,3 +33,14 @@ class IMultiselectClient(ABC):
:param stream: stream to communicate with multiselect over :param stream: stream to communicate with multiselect over
:return: selected protocol :return: selected protocol
""" """
async def try_select(
self, communicator: IMultiselectCommunicator, protocol: TProtocol
) -> TProtocol:
"""
Try to select the given protocol or raise exception if fails
:param communicator: communicator to use to communicate with counterparty
:param protocol: protocol to select
:raise Exception: error in protocol selection
:return: selected protocol
"""