mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-03-17 02:31:27 +00:00
Change IMuxedConn to INetConn in Notifee
This commit is contained in:
@ -77,7 +77,7 @@ class SwarmConn(INetConn):
|
||||
|
||||
async def _notify_disconnected(self) -> None:
|
||||
for notifee in self.swarm.notifees:
|
||||
await notifee.disconnected(self.swarm, self.conn)
|
||||
await notifee.disconnected(self.swarm, self)
|
||||
|
||||
async def start(self) -> None:
|
||||
await self.run_task(self._handle_new_streams())
|
||||
|
||||
@ -3,8 +3,8 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from multiaddr import Multiaddr
|
||||
|
||||
from libp2p.network.connection.net_connection_interface import INetConn
|
||||
from libp2p.network.stream.net_stream_interface import INetStream
|
||||
from libp2p.stream_muxer.abc import IMuxedConn
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .network_interface import INetwork # noqa: F401
|
||||
@ -26,14 +26,14 @@ class INotifee(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
async def connected(self, network: "INetwork", conn: IMuxedConn) -> None:
|
||||
async def connected(self, network: "INetwork", conn: INetConn) -> None:
|
||||
"""
|
||||
:param network: network the connection was opened on
|
||||
:param conn: connection that was opened
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
async def disconnected(self, network: "INetwork", conn: IMuxedConn) -> None:
|
||||
async def disconnected(self, network: "INetwork", conn: INetConn) -> None:
|
||||
"""
|
||||
:param network: network the connection was closed on
|
||||
:param conn: connection that was closed
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from libp2p.stream_muxer.abc import IMuxedConn, IMuxedStream
|
||||
from libp2p.stream_muxer.abc import IMuxedStream
|
||||
from libp2p.stream_muxer.exceptions import (
|
||||
MuxedStreamClosed,
|
||||
MuxedStreamEOF,
|
||||
@ -16,13 +16,11 @@ from .net_stream_interface import INetStream
|
||||
class NetStream(INetStream):
|
||||
|
||||
muxed_stream: IMuxedStream
|
||||
# TODO: Why we expose `mplex_conn` here?
|
||||
mplex_conn: IMuxedConn
|
||||
protocol_id: TProtocol
|
||||
|
||||
def __init__(self, muxed_stream: IMuxedStream) -> None:
|
||||
self.muxed_stream = muxed_stream
|
||||
self.mplex_conn = muxed_stream.mplex_conn
|
||||
self.muxed_conn = muxed_stream.muxed_conn
|
||||
self.protocol_id = None
|
||||
|
||||
def get_protocol(self) -> TProtocol:
|
||||
|
||||
@ -7,7 +7,7 @@ from libp2p.typing import TProtocol
|
||||
|
||||
class INetStream(ReadWriteCloser):
|
||||
|
||||
mplex_conn: IMuxedConn
|
||||
muxed_conn: IMuxedConn
|
||||
|
||||
@abstractmethod
|
||||
def get_protocol(self) -> TProtocol:
|
||||
|
||||
@ -278,8 +278,7 @@ class Swarm(INetwork):
|
||||
self.connections[muxed_conn.peer_id] = swarm_conn
|
||||
# Call notifiers since event occurred
|
||||
for notifee in self.notifees:
|
||||
# TODO: Call with other type of conn?
|
||||
await notifee.connected(self, muxed_conn)
|
||||
await notifee.connected(self, swarm_conn)
|
||||
await swarm_conn.start()
|
||||
return swarm_conn
|
||||
|
||||
|
||||
Reference in New Issue
Block a user