Skip to content

Commit

Permalink
Fixed inconsistent method resolution in UDP Streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Aratz M. Lasa committed Oct 16, 2019
1 parent 21f8105 commit 31bb77e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion libp2p/transport/tcp/tcp_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TCPStreamReader(TCPStream, IStreamReader):
_read_stream: StreamReader

def __init__(self, read_stream: StreamReader, write_stream: StreamWriter):
super().__init__(write_stream)
TCPStream.__init__(self, write_stream)
self._read_stream = read_stream

async def read(self, n: int = -1) -> bytes:
Expand Down
24 changes: 12 additions & 12 deletions libp2p/transport/udp/udp_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any

from asyncio_dgram.aio import DatagramStream

from libp2p.transport.stream_interface import IStream, IStreamReader, IStreamWriter
from libp2p.transport.udp.udp import UDPServer

Expand All @@ -27,7 +28,7 @@ class UDPStreamReader(UDPStream, IStreamReader):
_read_stream: BytesIO

def __init__(self, stream: DatagramStream):
super().__init__(stream)
UDPStream.__init__(self, stream)
self._read_stream = BytesIO()

async def read(self, n: int = -1) -> bytes:
Expand All @@ -49,19 +50,18 @@ class UDPStreamWriter(UDPStream, IStreamWriter):
_addr: Any

def __init__(self, stream: DatagramStream, addr: Any = None):
super().__init__(stream)
UDPStream.__init__(self, stream)
self._addr = addr

async def write(self, data: bytes) -> None:
await self._stream.send(data, addr=self._addr)


class UDPServerStream(UDPStream):
class UDPServerStream:
_server: UDPServer
_addr: Any

def __init__(self, stream: DatagramStream, server: UDPServer, addr: Any):
super().__init__(stream)
def __init__(self, server: UDPServer, addr: Any):
self._server = server
self._addr = addr

Expand All @@ -74,14 +74,14 @@ class UDPServerStreamReader(UDPServerStream, UDPStreamReader):
_queue: asyncio.Queue[bytes]

def __init__(
self,
stream: DatagramStream,
server: UDPServer,
addr: Any,
queue: asyncio.Queue[bytes],
self,
stream: DatagramStream,
server: UDPServer,
addr: Any,
queue: asyncio.Queue[bytes],
):
UDPStreamReader.__init__(self, stream)
UDPServerStream.__init__(self, stream, server, addr)
UDPServerStream.__init__(self, server, addr)
self._queue = queue

async def _fill_read_stream(self) -> None:
Expand All @@ -93,4 +93,4 @@ async def _fill_read_stream(self) -> None:
class UDPServerStreamWriter(UDPServerStream, UDPStreamWriter):
def __init__(self, stream: DatagramStream, server: UDPServer, addr: Any):
UDPStreamWriter.__init__(self, stream, addr)
UDPServerStream.__init__(self, stream, server, addr)
UDPServerStream.__init__(self, server, addr)

0 comments on commit 31bb77e

Please sign in to comment.