move transport to swarm constructor

This commit is contained in:
zixuanzh
2019-04-24 22:36:09 -04:00
parent fc4fc74b87
commit 35f75c4dcd
2 changed files with 11 additions and 13 deletions

View File

@ -12,14 +12,14 @@ from .connection.raw_connection import RawConnection
class Swarm(INetwork):
# pylint: disable=too-many-instance-attributes, cell-var-from-loop
def __init__(self, peer_id, peerstore, upgrader):
def __init__(self, peer_id, peerstore, upgrader, transport):
self.self_id = peer_id
self.peerstore = peerstore
self.upgrader = upgrader
self.transport = transport
self.connections = dict()
self.listeners = dict()
self.stream_handlers = dict()
self.transport = None
# Protocol muxing
self.multiselect = Multiselect()
@ -183,10 +183,6 @@ class Swarm(INetwork):
return True
return False
def add_transport(self, transport):
# TODO: Support more than one transport
self.transport = transport
def create_generic_protocol_handler(swarm):
"""
Create a generic protocol handler from the given swarm. We use swarm