mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
add typing to protocol_muxer
This commit is contained in:
committed by
Kevin Mai-Husan Chia
parent
0d709364f8
commit
5903012e0e
@ -1,4 +1,8 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Sequence
|
||||
|
||||
from libp2p.stream_muxer.abc import IMuxedStream
|
||||
from libp2p.typing import TProtocol
|
||||
|
||||
|
||||
class IMultiselectClient(ABC):
|
||||
@ -8,7 +12,7 @@ class IMultiselectClient(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def select_protocol_or_fail(self, protocol, stream):
|
||||
async def select_protocol_or_fail(self, protocol: TProtocol, stream: IMuxedStream) -> TProtocol:
|
||||
"""
|
||||
Send message to multiselect selecting protocol
|
||||
and fail if multiselect does not return same protocol
|
||||
@ -18,7 +22,9 @@ class IMultiselectClient(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def select_one_of(self, protocols, stream):
|
||||
async def select_one_of(
|
||||
self, protocols: Sequence[TProtocol], stream: IMuxedStream
|
||||
) -> TProtocol:
|
||||
"""
|
||||
For each protocol, send message to multiselect selecting protocol
|
||||
and fail if multiselect does not return same protocol. Returns first
|
||||
|
||||
Reference in New Issue
Block a user