Modify stream to use connection
This commit is contained in:
parent
bab97f5648
commit
ad7a449f6e
|
@ -3,17 +3,14 @@ import asyncio
|
|||
|
||||
class Stream(IStream):
|
||||
|
||||
def __init__(self, peer_id, multi_addr):
|
||||
def __init__(self, peer_id, multi_addr, connection):
|
||||
IStream.__init__(self, peer_id, multi_addr)
|
||||
self.peer_id = peer_id
|
||||
|
||||
ip = multi_addr.get_protocol_value("ip4")
|
||||
port = multi_addr.get_protocol_value("tcp")
|
||||
|
||||
self.open_connection(ip, port)
|
||||
|
||||
async def open_connection(self, ip, port):
|
||||
self.reader, self.writer = await asyncio.open_connection(ip, port)
|
||||
self.reader = connection.reader
|
||||
self.writer = connection.writer
|
||||
|
||||
def protocol(self):
|
||||
"""
|
||||
|
|
|
@ -2,9 +2,10 @@ from abc import ABC, abstractmethod
|
|||
|
||||
class IStream(ABC):
|
||||
|
||||
def __init__(self, peer_id, multi_addr):
|
||||
def __init__(self, peer_id, multi_addr, connection):
|
||||
self.peer_id = peer_id
|
||||
self.multi_addr = multi_addr
|
||||
self.connection = connection
|
||||
|
||||
@abstractmethod
|
||||
def protocol(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user