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
"""
@abstractmethod
async def select_protocol_or_fail(
self, protocol: TProtocol, communicator: IMultiselectCommunicator
) -> TProtocol:
async def handshake(self, communicator: IMultiselectCommunicator) -> None:
"""
Send message to multiselect selecting protocol
and fail if multiselect does not return same protocol
:param protocol: protocol to select
Ensure that the client and multiselect
are both using the same multiselect protocol
:param stream: stream to communicate with multiselect over
:return: selected protocol
:raise Exception: multiselect protocol ID mismatch
"""
@abstractmethod
@ -37,3 +33,14 @@ class IMultiselectClient(ABC):
:param stream: stream to communicate with multiselect over
: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
"""