mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 16:10:57 +00:00
started on stream
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
from .stream_interface import IStream
|
from .stream_interface import IStream
|
||||||
|
import asyncio
|
||||||
|
|
||||||
class Stream(IStream):
|
class Stream(IStream):
|
||||||
|
|
||||||
@ -6,18 +7,30 @@ class Stream(IStream):
|
|||||||
self.context = context
|
self.context = context
|
||||||
self.peer_id = peer_id
|
self.peer_id = peer_id
|
||||||
|
|
||||||
|
peer_store = context.peer_store
|
||||||
|
peer_addr = peer_store.get(peer_id)
|
||||||
|
|
||||||
|
# look up peer_id -> multiaddr in peer store
|
||||||
|
# parse multiaddr and set_protocol based on it
|
||||||
|
# open connection to multiaddr
|
||||||
|
# save connection to stream's state
|
||||||
|
self.open_connection(ip, port)
|
||||||
|
|
||||||
|
async def open_connection(self, ip, port):
|
||||||
|
self.reader, self.writer = await asyncio.open_connection(ip, port)
|
||||||
|
|
||||||
def protocol(self):
|
def protocol(self):
|
||||||
"""
|
"""
|
||||||
:return: protocol id that stream runs on
|
:return: protocol id that stream runs on
|
||||||
"""
|
"""
|
||||||
pass
|
return self.protocol_id
|
||||||
|
|
||||||
def set_protocol(self, protocol_id):
|
def set_protocol(self, protocol_id):
|
||||||
"""
|
"""
|
||||||
:param protocol_id: protocol id that stream runs on
|
:param protocol_id: protocol id that stream runs on
|
||||||
:return: true if successful
|
:return: true if successful
|
||||||
"""
|
"""
|
||||||
pass
|
self.protocol_id = protocol_id
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
asyncio
|
||||||
Reference in New Issue
Block a user