def __init__(self, secure_transports_by_protocol: TSecurityOptions) -> None:
        self.transports = OrderedDict()
        self.multiselect = Multiselect()
        self.multiselect_client = MultiselectClient()

        for protocol, transport in secure_transports_by_protocol.items():
            self.add_transport(protocol, transport)
Exemplo n.º 2
0
    def __init__(
        self,
        peer_id: ID,
        peerstore: IPeerStore,
        upgrader: TransportUpgrader,
        transport: ITransport,
        router: IPeerRouting,
    ):
        self.self_id = peer_id
        self.peerstore = peerstore
        self.upgrader = upgrader
        self.transport = transport
        self.router = router
        self.connections = dict()
        self.listeners = dict()
        self.stream_handlers = dict()

        # Protocol muxing
        self.multiselect = Multiselect()
        self.multiselect_client = MultiselectClient()

        # Create Notifee array
        self.notifees = []

        # Create generic protocol handler
        self.generic_protocol_handler = create_generic_protocol_handler(self)
Exemplo n.º 3
0
 def __init__(
     self, muxer_transports_by_protocol: Mapping[TProtocol,
                                                 MuxerClassType]) -> None:
     self.transports = OrderedDict()
     self.multiselect = Multiselect()
     self.multiselect_client = MultiselectClient()
     for protocol, transport in muxer_transports_by_protocol.items():
         self.add_transport(protocol, transport)
Exemplo n.º 4
0
    def __init__(self):
        # Map protocol to secure transport
        self.transports = {}

        # Create multiselect
        self.multiselect = Multiselect()

        # Create multiselect client
        self.multiselect_client = MultiselectClient()
Exemplo n.º 5
0
    def __init__(
        self, secure_transports_by_protocol: Mapping[TProtocol,
                                                     ISecureTransport]
    ) -> None:
        self.transports = OrderedDict()
        self.multiselect = Multiselect()
        self.multiselect_client = MultiselectClient()

        for protocol, transport in secure_transports_by_protocol.items():
            self.add_transport(protocol, transport)
Exemplo n.º 6
0
 def __init__(self,
              network: INetwork,
              router: KadmeliaPeerRouter = None) -> None:
     self._network = network
     self._network.set_stream_handler(self._swarm_stream_handler)
     self._router = router
     self.peerstore = self._network.peerstore
     # Protocol muxing
     self.multiselect = Multiselect()
     self.multiselect_client = MultiselectClient()
Exemplo n.º 7
0
 def __init__(
     self,
     network: INetworkService,
     default_protocols: "OrderedDict[TProtocol, StreamHandlerFn]" = None,
 ) -> None:
     self._network = network
     self._network.set_stream_handler(self._swarm_stream_handler)
     self.peerstore = self._network.peerstore
     # Protocol muxing
     default_protocols = default_protocols or get_default_protocols(self)
     self.multiselect = Multiselect(default_protocols)
     self.multiselect_client = MultiselectClient()
Exemplo n.º 8
0
    def __init__(self, peer_id, peerstore, upgrader):
        self.self_id = peer_id
        self.peerstore = peerstore
        self.upgrader = upgrader
        self.connections = dict()
        self.listeners = dict()
        self.stream_handlers = dict()
        self.transport = None

        # Protocol muxing
        self.multiselect = Multiselect()
        self.multiselect_client = MultiselectClient()

        # Create generic protocol handler
        self.generic_protocol_handler = create_generic_protocol_handler(self)
Exemplo n.º 9
0
 def __init__(self, muxer_transports_by_protocol: TMuxerOptions) -> None:
     self.transports = OrderedDict()
     self.multiselect = Multiselect()
     self.multiselect_client = MultiselectClient()
     for protocol, transport in muxer_transports_by_protocol.items():
         self.add_transport(protocol, transport)