mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Add delim_encode and delim_read
- Add `StreamCommunicator` and `RawConnectionCommunicator`, read/write messages with delim codec, with `IMuxedStream` and `IRawConnection` respectively. - Use it in `Multiselect` and `MultiselectClient`.
This commit is contained in:
committed by
Kevin Mai-Husan Chia
parent
8cd23abfe2
commit
86d4ce1da8
@ -1,7 +1,9 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Sequence
|
||||
|
||||
from libp2p.stream_muxer.abc import IMuxedStream
|
||||
from libp2p.protocol_muxer.multiselect_communicator_interface import (
|
||||
IMultiselectCommunicator,
|
||||
)
|
||||
from libp2p.typing import TProtocol
|
||||
|
||||
|
||||
@ -13,7 +15,7 @@ class IMultiselectClient(ABC):
|
||||
|
||||
@abstractmethod
|
||||
async def select_protocol_or_fail(
|
||||
self, protocol: TProtocol, stream: IMuxedStream
|
||||
self, protocol: TProtocol, communicator: IMultiselectCommunicator
|
||||
) -> TProtocol:
|
||||
"""
|
||||
Send message to multiselect selecting protocol
|
||||
@ -25,7 +27,7 @@ class IMultiselectClient(ABC):
|
||||
|
||||
@abstractmethod
|
||||
async def select_one_of(
|
||||
self, protocols: Sequence[TProtocol], stream: IMuxedStream
|
||||
self, protocols: Sequence[TProtocol], communicator: IMultiselectCommunicator
|
||||
) -> TProtocol:
|
||||
"""
|
||||
For each protocol, send message to multiselect selecting protocol
|
||||
|
||||
Reference in New Issue
Block a user