py-libp2p/transport/upgrader.py

28 lines
643 B
Python
Raw Normal View History

2018-11-21 09:28:41 +08:00
from stream_muxer.mplex.mplex import Mplex
2018-11-12 08:37:07 +08:00
2018-11-13 02:02:49 +08:00
class TransportUpgrader():
2018-11-11 22:56:44 +08:00
def __init__(self, secOpt, muxerOpt):
self.sec = secOpt
self.muxer = muxerOpt
2018-11-11 22:56:44 +08:00
def upgrade_listener(self, transport, listeners):
"""
upgrade multiaddr listeners to libp2p-transport listeners
2018-11-11 22:56:44 +08:00
"""
pass
2018-11-13 02:02:49 +08:00
def upgrade_security(self):
pass
2018-11-11 22:56:44 +08:00
2018-11-12 08:37:07 +08:00
def upgrade_connection(self, conn, initiator):
"""
upgrade raw connection to muxed connection
"""
2018-11-13 02:02:49 +08:00
# For PoC, no security, default to mplex
2018-11-12 08:37:07 +08:00
# TODO do exchange to determine multiplexer
2018-11-21 09:28:41 +08:00
return Mplex(conn, initiator)