@@ -19,7 +19,6 @@ pub(crate) use plain_tcp::PlainTcpInstantiator;
19
19
pub ( crate ) use project:: ProjectInstantiator ;
20
20
pub ( crate ) use secure:: SecureChannelInstantiator ;
21
21
use std:: fmt:: { Debug , Formatter } ;
22
- use std:: sync:: Arc ;
23
22
24
23
#[ derive( Clone ) ]
25
24
pub struct Connection {
@@ -43,18 +42,18 @@ pub struct Connection {
43
42
44
43
impl Connection {
45
44
/// Shorthand to add the address as consumer to the flow control
46
- pub fn add_consumer ( & self , context : Arc < Context > , address : & Address ) {
45
+ pub fn add_consumer ( & self , context : & Context , address : & Address ) {
47
46
if let Some ( flow_control_id) = & self . flow_control_id {
48
47
context
49
48
. flow_controls ( )
50
49
. add_consumer ( address. clone ( ) , flow_control_id) ;
51
50
}
52
51
}
53
52
54
- pub fn add_default_consumers ( & self , ctx : Arc < Context > ) {
55
- self . add_consumer ( ctx. clone ( ) , & DefaultAddress :: KEY_EXCHANGER_LISTENER . into ( ) ) ;
56
- self . add_consumer ( ctx. clone ( ) , & DefaultAddress :: SECURE_CHANNEL_LISTENER . into ( ) ) ;
57
- self . add_consumer ( ctx. clone ( ) , & DefaultAddress :: UPPERCASE_SERVICE . into ( ) ) ;
53
+ pub fn add_default_consumers ( & self , ctx : & Context ) {
54
+ self . add_consumer ( ctx, & DefaultAddress :: KEY_EXCHANGER_LISTENER . into ( ) ) ;
55
+ self . add_consumer ( ctx, & DefaultAddress :: SECURE_CHANNEL_LISTENER . into ( ) ) ;
56
+ self . add_consumer ( ctx, & DefaultAddress :: UPPERCASE_SERVICE . into ( ) ) ;
58
57
self . add_consumer ( ctx, & DefaultAddress :: ECHO_SERVICE . into ( ) ) ;
59
58
}
60
59
@@ -182,7 +181,7 @@ pub trait Instantiator: Send + Sync + 'static {
182
181
/// The returned [`Changes`] will be used to update the builder state.
183
182
async fn instantiate (
184
183
& self ,
185
- ctx : Arc < Context > ,
184
+ ctx : & Context ,
186
185
node_manager : & NodeManager ,
187
186
transport_route : Route ,
188
187
extracted : ( MultiAddr , MultiAddr , MultiAddr ) ,
@@ -217,7 +216,7 @@ impl ConnectionBuilder {
217
216
/// user make sure higher protocol abstraction are called before lower level ones
218
217
pub async fn instantiate (
219
218
mut self ,
220
- ctx : Arc < Context > ,
219
+ ctx : & Context ,
221
220
node_manager : & NodeManager ,
222
221
instantiator : impl Instantiator ,
223
222
) -> Result < Self , ockam_core:: Error > {
@@ -233,14 +232,14 @@ impl ConnectionBuilder {
233
232
// the transport route should include only the pieces before the match
234
233
self . transport_route = self
235
234
. recalculate_transport_route (
236
- & ctx,
235
+ ctx,
237
236
self . current_multiaddr . split ( start) . 0 ,
238
237
false ,
239
238
)
240
239
. await ?;
241
240
let mut changes = instantiator
242
241
. instantiate (
243
- ctx. clone ( ) ,
242
+ ctx,
244
243
node_manager,
245
244
self . transport_route . clone ( ) ,
246
245
self . extract ( start, instantiator. matches ( ) . len ( ) ) ,
@@ -271,7 +270,7 @@ impl ConnectionBuilder {
271
270
}
272
271
273
272
self . transport_route = self
274
- . recalculate_transport_route ( & ctx, self . current_multiaddr . clone ( ) , true )
273
+ . recalculate_transport_route ( ctx, self . current_multiaddr . clone ( ) , true )
275
274
. await ?;
276
275
277
276
Ok ( Self {
0 commit comments