mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-09 22:50:54 +00:00
Modify NetStream to read n bytes
This commit is contained in:
committed by
Kevin Mai-Husan Chia
parent
dbdbcf7440
commit
2485a00e24
@ -28,12 +28,13 @@ class NetStream(INetStream):
|
||||
"""
|
||||
self.protocol_id = protocol_id
|
||||
|
||||
async def read(self) -> bytes:
|
||||
async def read(self, n: int = -1) -> bytes:
|
||||
"""
|
||||
read from stream
|
||||
:return: bytes of input until EOF
|
||||
reads from stream
|
||||
:param n: number of bytes to read
|
||||
:return: bytes of input
|
||||
"""
|
||||
return await self.muxed_stream.read()
|
||||
return await self.muxed_stream.read(n)
|
||||
|
||||
async def write(self, data: bytes) -> int:
|
||||
"""
|
||||
|
||||
@ -22,9 +22,10 @@ class INetStream(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
async def read(self) -> bytes:
|
||||
async def read(self, n: int = -1) -> bytes:
|
||||
"""
|
||||
reads from the underlying muxed_stream
|
||||
:param n: number of bytes to read
|
||||
:return: bytes of input
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user