mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-11 15:40:54 +00:00
Merge branch 'master' of https://github.com/zixuanzh/py-libp2p into mux-conn
This commit is contained in:
0
network/connection/__init__.py
Normal file
0
network/connection/__init__.py
Normal file
26
network/connection/raw_connection.py
Normal file
26
network/connection/raw_connection.py
Normal file
@ -0,0 +1,26 @@
|
||||
import asyncio
|
||||
from .raw_connection_interface import IRawConnection
|
||||
|
||||
class RawConnection(IRawConnection):
|
||||
|
||||
def __init__(self, ip, port, reader, writer):
|
||||
self.conn_ip = ip
|
||||
self.conn_port = port
|
||||
self.reader = reader
|
||||
self.writer = writer
|
||||
|
||||
|
||||
def close(self):
|
||||
self.writer.close()
|
||||
|
||||
# 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)
|
||||
15
network/connection/raw_connection_interface.py
Normal file
15
network/connection/raw_connection_interface.py
Normal file
@ -0,0 +1,15 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
class IRawConnection(ABC):
|
||||
"""
|
||||
A Raw Connection provides a Reader and a Writer
|
||||
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
|
||||
Reference in New Issue
Block a user