mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Change default value of read()
From `n = -1` to `n = None`, to comply with trio API
This commit is contained in:
@ -39,7 +39,7 @@ class InsecureSession(BaseSession):
|
||||
await self.conn.write(data)
|
||||
return len(data)
|
||||
|
||||
async def read(self, n: int = -1) -> bytes:
|
||||
async def read(self, n: int = None) -> bytes:
|
||||
return await self.conn.read(n)
|
||||
|
||||
async def close(self) -> None:
|
||||
|
||||
@ -94,7 +94,7 @@ class SecureSession(BaseSession):
|
||||
|
||||
data = self.buf.getbuffer()[self.low_watermark : self.high_watermark]
|
||||
|
||||
if n < 0:
|
||||
if n is None:
|
||||
n = len(data)
|
||||
result = data[:n].tobytes()
|
||||
self.low_watermark += len(result)
|
||||
@ -111,7 +111,7 @@ class SecureSession(BaseSession):
|
||||
self.low_watermark = 0
|
||||
self.high_watermark = len(msg)
|
||||
|
||||
async def read(self, n: int = -1) -> bytes:
|
||||
async def read(self, n: int = None) -> bytes:
|
||||
if n == 0:
|
||||
return bytes()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user