mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 16:10:57 +00:00
restructured raw connection
This commit is contained in:
@ -3,14 +3,20 @@ from .raw_connection_interface import IRawConnection
|
||||
|
||||
class RawConnection(IRawConnection):
|
||||
|
||||
def __init__(self, ip, port):
|
||||
def __init__(self, ip, port, reader, writer):
|
||||
self.conn_ip = ip
|
||||
self.conn_port = port
|
||||
self.reader, self.writer = self.open_connection()
|
||||
self.reader = reader
|
||||
self.writer = writer
|
||||
|
||||
async def open_connection(self):
|
||||
"""
|
||||
opens a connection on self.ip and self.port
|
||||
:return: a raw connection
|
||||
"""
|
||||
return await asyncio.open_connection(self.conn_ip, self.conn_port)
|
||||
# def __init__(self, ip, port):
|
||||
# self.conn_ip = ip
|
||||
# self.conn_port = port
|
||||
# self.reader, self.writer = self.open_connection()
|
||||
|
||||
# async def open_connection(self):
|
||||
# """
|
||||
# opens a connection on self.ip and self.port
|
||||
# :return: a raw connection
|
||||
# """
|
||||
# return await asyncio.open_connection(self.conn_ip, self.conn_port)
|
||||
|
||||
@ -6,10 +6,10 @@ class IRawConnection(ABC):
|
||||
open_connection should return such a connection
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
async def open_connection(self):
|
||||
"""
|
||||
opens a connection on ip and port
|
||||
:return: a raw connection
|
||||
"""
|
||||
pass
|
||||
# @abstractmethod
|
||||
# async def open_connection(self):
|
||||
# """
|
||||
# opens a connection on ip and port
|
||||
# :return: a raw connection
|
||||
# """
|
||||
# pass
|
||||
|
||||
Reference in New Issue
Block a user