|
@@ -271,10 +271,9 @@ class P2P:
|
|
|
async def receive_raw_data(reader: asyncio.StreamReader, *, chunk_size: int = 2 ** 16) -> bytes:
|
|
|
header = await reader.readexactly(P2P.HEADER_LEN)
|
|
|
content_length = int.from_bytes(header, P2P.BYTEORDER)
|
|
|
- print('CL:', content_length)
|
|
|
data = bytearray(content_length)
|
|
|
for offset in range(0, content_length, chunk_size):
|
|
|
- data[offset : offset + chunk_size] = await reader.readexactly(chunk_size)
|
|
|
+ data[offset : offset + chunk_size] = await reader.readexactly(min(chunk_size, len(data) - offset))
|
|
|
return data
|
|
|
|
|
|
TInputProtobuf = TypeVar("TInputProtobuf")
|