mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-09 14:40:53 +00:00
Fix all modules except for security
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
import trio
|
||||
|
||||
from libp2p.io.abc import ReadWriteCloser
|
||||
from libp2p.io.exceptions import IOException
|
||||
|
||||
@ -8,17 +6,17 @@ from .raw_connection_interface import IRawConnection
|
||||
|
||||
|
||||
class RawConnection(IRawConnection):
|
||||
read_write_closer: ReadWriteCloser
|
||||
stream: ReadWriteCloser
|
||||
is_initiator: bool
|
||||
|
||||
def __init__(self, read_write_closer: ReadWriteCloser, initiator: bool) -> None:
|
||||
self.read_write_closer = read_write_closer
|
||||
def __init__(self, stream: ReadWriteCloser, initiator: bool) -> None:
|
||||
self.stream = stream
|
||||
self.is_initiator = initiator
|
||||
|
||||
async def write(self, data: bytes) -> None:
|
||||
"""Raise `RawConnError` if the underlying connection breaks."""
|
||||
try:
|
||||
await self.read_write_closer.write(data)
|
||||
await self.stream.write(data)
|
||||
except IOException as error:
|
||||
raise RawConnError(error)
|
||||
|
||||
@ -30,9 +28,9 @@ class RawConnection(IRawConnection):
|
||||
Raise `RawConnError` if the underlying connection breaks
|
||||
"""
|
||||
try:
|
||||
return await self.read_write_closer.read(n)
|
||||
return await self.stream.read(n)
|
||||
except IOException as error:
|
||||
raise RawConnError(error)
|
||||
|
||||
async def close(self) -> None:
|
||||
await self.read_write_closer.close()
|
||||
await self.stream.close()
|
||||
|
||||
Reference in New Issue
Block a user