@@ -32,6 +32,7 @@ use libp2p_identity::PeerId;
32
32
use libp2p_identity:: PublicKey ;
33
33
use libp2p_swarm:: handler:: {
34
34
ConnectionEvent , DialUpgradeError , FullyNegotiatedInbound , FullyNegotiatedOutbound ,
35
+ ProtocolsChange ,
35
36
} ;
36
37
use libp2p_swarm:: {
37
38
ConnectionHandler , ConnectionHandlerEvent , ConnectionHandlerUpgrErr , KeepAlive ,
@@ -83,6 +84,8 @@ pub struct Handler {
83
84
84
85
/// Address observed by or for the remote.
85
86
observed_addr : Multiaddr ,
87
+
88
+ local_supported_protocols : Vec < String > ,
86
89
}
87
90
88
91
/// An event from `Behaviour` with the information requested by the `Handler`.
@@ -91,9 +94,6 @@ pub struct InEvent {
91
94
/// The addresses that the peer is listening on.
92
95
pub listen_addrs : Vec < Multiaddr > ,
93
96
94
- /// The list of protocols supported by the peer, e.g. `/ipfs/ping/1.0.0`.
95
- pub supported_protocols : Vec < String > ,
96
-
97
97
/// The protocol w.r.t. the information requested.
98
98
pub protocol : Protocol ,
99
99
}
@@ -138,6 +138,7 @@ impl Handler {
138
138
protocol_version,
139
139
agent_version,
140
140
observed_addr,
141
+ local_supported_protocols : vec ! [ ] ,
141
142
}
142
143
}
143
144
@@ -238,7 +239,6 @@ impl ConnectionHandler for Handler {
238
239
& mut self ,
239
240
InEvent {
240
241
listen_addrs,
241
- supported_protocols,
242
242
protocol,
243
243
} : Self :: InEvent ,
244
244
) {
@@ -247,7 +247,7 @@ impl ConnectionHandler for Handler {
247
247
protocol_version : self . protocol_version . clone ( ) ,
248
248
agent_version : self . agent_version . clone ( ) ,
249
249
listen_addrs,
250
- protocols : supported_protocols ,
250
+ protocols : self . local_supported_protocols . clone ( ) ,
251
251
observed_addr : self . observed_addr . clone ( ) ,
252
252
} ;
253
253
@@ -344,9 +344,10 @@ impl ConnectionHandler for Handler {
344
344
ConnectionEvent :: DialUpgradeError ( dial_upgrade_error) => {
345
345
self . on_dial_upgrade_error ( dial_upgrade_error)
346
346
}
347
- ConnectionEvent :: AddressChange ( _)
348
- | ConnectionEvent :: ListenUpgradeError ( _)
349
- | ConnectionEvent :: LocalProtocolsChange ( _) => { }
347
+ ConnectionEvent :: AddressChange ( _) | ConnectionEvent :: ListenUpgradeError ( _) => { }
348
+ ConnectionEvent :: LocalProtocolsChange ( ProtocolsChange { protocols } ) => {
349
+ self . local_supported_protocols = protocols. to_vec ( ) ;
350
+ }
350
351
ConnectionEvent :: RemoteProtocolsChange ( _) => { }
351
352
}
352
353
}
0 commit comments