@@ -142,21 +142,28 @@ impl From<KadPeer> for proto::message::Peer {
142142// `OutboundUpgrade` to be just a single message
143143#[ derive( Debug , Clone ) ]
144144pub struct KademliaProtocolConfig {
145- protocol_name : Cow < ' static , [ u8 ] > ,
145+ protocol_names : Vec < Cow < ' static , [ u8 ] > > ,
146146 /// Maximum allowed size of a packet.
147147 max_packet_size : usize ,
148148}
149149
150150impl KademliaProtocolConfig {
151151 /// Returns the configured protocol name.
152- pub fn protocol_name ( & self ) -> & [ u8 ] {
153- & self . protocol_name
152+ pub fn protocol_names ( & self ) -> & [ Cow < ' static , [ u8 ] > ] {
153+ & self . protocol_names
154154 }
155155
156- /// Modifies the protocol name used on the wire. Can be used to create incompatibilities
156+ /// Modifies the protocol names used on the wire. Can be used to create incompatibilities
157157 /// between networks on purpose.
158+ pub fn set_protocol_names ( & mut self , names : Vec < Cow < ' static , [ u8 ] > > ) {
159+ self . protocol_names = names;
160+ }
161+
162+ /// Sets single protocol name used on the wire. Can be used to create incompatibilities
163+ /// between networks on purpose.
164+ #[ deprecated( since = "0.40.0" , note = "use `set_protocol_names()` instead" ) ]
158165 pub fn set_protocol_name ( & mut self , name : impl Into < Cow < ' static , [ u8 ] > > ) {
159- self . protocol_name = name. into ( ) ;
166+ self . set_protocol_names ( std :: iter :: once ( name. into ( ) ) . collect ( ) ) ;
160167 }
161168
162169 /// Modifies the maximum allowed size of a single Kademlia packet.
@@ -168,18 +175,18 @@ impl KademliaProtocolConfig {
168175impl Default for KademliaProtocolConfig {
169176 fn default ( ) -> Self {
170177 KademliaProtocolConfig {
171- protocol_name : Cow :: Borrowed ( DEFAULT_PROTO_NAME ) ,
178+ protocol_names : iter :: once ( Cow :: Borrowed ( DEFAULT_PROTO_NAME ) ) . collect ( ) ,
172179 max_packet_size : DEFAULT_MAX_PACKET_SIZE ,
173180 }
174181 }
175182}
176183
177184impl UpgradeInfo for KademliaProtocolConfig {
178185 type Info = Cow < ' static , [ u8 ] > ;
179- type InfoIter = iter :: Once < Self :: Info > ;
186+ type InfoIter = std :: vec :: IntoIter < Self :: Info > ;
180187
181188 fn protocol_info ( & self ) -> Self :: InfoIter {
182- iter :: once ( self . protocol_name . clone ( ) )
189+ self . protocol_names . clone ( ) . into_iter ( )
183190 }
184191}
185192
0 commit comments