From 4b15cb1af5f5e50f641ac7964e7e2a41551721e8 Mon Sep 17 00:00:00 2001 From: NIC619 Date: Mon, 4 Nov 2019 14:23:00 +0800 Subject: [PATCH] Implement `PubsubNotifee.disconnected` --- libp2p/pubsub/pubsub_notifee.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libp2p/pubsub/pubsub_notifee.py b/libp2p/pubsub/pubsub_notifee.py index 25531244..6afa9ad2 100644 --- a/libp2p/pubsub/pubsub_notifee.py +++ b/libp2p/pubsub/pubsub_notifee.py @@ -49,7 +49,14 @@ class PubsubNotifee(INotifee): await self.initiator_peers_queue.put(conn.muxed_conn.peer_id) async def disconnected(self, network: INetwork, conn: INetConn) -> None: - pass + """ + Add peer_id to dead_peers_queue, so that pubsub and its router can + remove this peer_id and close the stream inbetween. + + :param network: network the connection was opened on + :param conn: connection that was opened + """ + await self.dead_peers_queue.put(conn.muxed_conn.peer_id) async def listen(self, network: INetwork, multiaddr: Multiaddr) -> None: pass