mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-03-25 14:41:28 +00:00
muxer scaffolding
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
from .muxed_connection_interface import IMuxedConnection
|
||||
from .muxed_connection_interface import IMuxedConn
|
||||
|
||||
class MuxedConnection(IMuxedConnection):
|
||||
class MuxedConn(IMuxedConn):
|
||||
"""
|
||||
reference: https://github.com/libp2p/go-mplex/blob/master/multiplex.go
|
||||
"""
|
||||
@ -26,7 +26,7 @@ class MuxedConnection(IMuxedConnection):
|
||||
"""
|
||||
pass
|
||||
|
||||
def open_stream(self):
|
||||
def open_stream(self, protocol_id, stream_name):
|
||||
"""
|
||||
creates a new muxed_stream
|
||||
:return: a new stream
|
||||
|
||||
@ -16,9 +16,11 @@ class IMuxedConn(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def open_stream(self):
|
||||
def open_stream(self, protocol_id, stream_name):
|
||||
"""
|
||||
creates a new muxed_stream
|
||||
:param protocol_id: id to be associated with stream
|
||||
:param stream_name: name as part of identifier
|
||||
:return: a new stream
|
||||
"""
|
||||
pass
|
||||
|
||||
@ -4,8 +4,9 @@ class MuxedStream(IMuxedStream):
|
||||
"""
|
||||
reference: https://github.com/libp2p/go-mplex/blob/master/stream.go
|
||||
"""
|
||||
def __init__(self, stream_id, stream_name):
|
||||
self.id = stream_id
|
||||
|
||||
def __init__(self, protocol_id, stream_name):
|
||||
self.protocol_id = protocol_id
|
||||
self.name = stream_name
|
||||
|
||||
def read(self):
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import time
|
||||
# from datetime import time
|
||||
|
||||
class IMuxedStream(ABC):
|
||||
|
||||
|
||||
@ -25,12 +25,12 @@ class Multiplex(object):
|
||||
"""
|
||||
return self.muxed_conn.is_closed()
|
||||
|
||||
def open_stream(self):
|
||||
def open_stream(self, protocol_id, stream_name):
|
||||
"""
|
||||
creates a new muxed_stream
|
||||
:return: a new stream
|
||||
"""
|
||||
return self.muxed_conn.open_stream()
|
||||
return self.muxed_conn.open_stream(protocol_id, stream_name)
|
||||
|
||||
def accept_stream(self, _muxed_stream):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user