@@ -50,7 +50,8 @@ use crate::{
5050 raw_swarm:: { RawSwarm , RawSwarmEvent }
5151 } ,
5252 protocols_handler:: { NodeHandlerWrapper , ProtocolsHandler } ,
53- topology:: Topology
53+ topology:: Topology ,
54+ topology:: DisconnectReason ,
5455} ;
5556use futures:: prelude:: * ;
5657use smallvec:: SmallVec ;
@@ -268,13 +269,20 @@ where TBehaviour: NetworkBehaviour<TTopology>,
268269 self . behaviour . inject_node_event ( peer_id, event) ;
269270 } ,
270271 Async :: Ready ( RawSwarmEvent :: Connected { peer_id, endpoint } ) => {
272+ self . topology . set_connected ( & peer_id, & endpoint) ;
271273 self . behaviour . inject_connected ( peer_id, endpoint) ;
272274 } ,
273- Async :: Ready ( RawSwarmEvent :: NodeClosed { peer_id, endpoint } ) |
275+ Async :: Ready ( RawSwarmEvent :: NodeClosed { peer_id, endpoint } ) => {
276+ self . topology . set_disconnected ( & peer_id, & endpoint, DisconnectReason :: Graceful ) ;
277+ self . behaviour . inject_disconnected ( & peer_id, endpoint) ;
278+ } ,
274279 Async :: Ready ( RawSwarmEvent :: NodeError { peer_id, endpoint, .. } ) => {
280+ self . topology . set_disconnected ( & peer_id, & endpoint, DisconnectReason :: Error ) ;
275281 self . behaviour . inject_disconnected ( & peer_id, endpoint) ;
276282 } ,
277283 Async :: Ready ( RawSwarmEvent :: Replaced { peer_id, closed_endpoint, endpoint } ) => {
284+ self . topology . set_disconnected ( & peer_id, & closed_endpoint, DisconnectReason :: Replaced ) ;
285+ self . topology . set_connected ( & peer_id, & endpoint) ;
278286 self . behaviour . inject_disconnected ( & peer_id, closed_endpoint) ;
279287 self . behaviour . inject_connected ( peer_id, endpoint) ;
280288 } ,
@@ -284,8 +292,12 @@ where TBehaviour: NetworkBehaviour<TTopology>,
284292 } ,
285293 Async :: Ready ( RawSwarmEvent :: ListenerClosed { .. } ) => { } ,
286294 Async :: Ready ( RawSwarmEvent :: IncomingConnectionError { .. } ) => { } ,
287- Async :: Ready ( RawSwarmEvent :: DialError { .. } ) => { } ,
288- Async :: Ready ( RawSwarmEvent :: UnknownPeerDialError { .. } ) => { } ,
295+ Async :: Ready ( RawSwarmEvent :: DialError { multiaddr, .. } ) => {
296+ self . topology . set_unreachable ( & multiaddr) ;
297+ } ,
298+ Async :: Ready ( RawSwarmEvent :: UnknownPeerDialError { multiaddr, .. } ) => {
299+ self . topology . set_unreachable ( & multiaddr) ;
300+ } ,
289301 }
290302
291303 let behaviour_poll = {
0 commit comments