@@ -76,8 +76,12 @@ async fn remove_sub_on_stop(p2p: P2pPtr, channel: ChannelPtr) {
76
76
pub trait Session : Sync {
77
77
/// Registers a new channel with the session. Performs a network handshake
78
78
/// and starts the channel.
79
+ // if we need to pass Self as an Arc we can do so like this:
80
+ // pub trait MyTrait: Send + Sync {
81
+ // async fn foo(&self, self_: Arc<dyn MyTrait>) {}
82
+ // }
79
83
async fn register_channel (
80
- self_ : Arc < dyn Session > ,
84
+ & self ,
81
85
channel : ChannelPtr ,
82
86
executor : Arc < Executor < ' _ > > ,
83
87
) -> Result < ( ) > {
@@ -87,14 +91,14 @@ pub trait Session: Sync {
87
91
// We do this so that the protocols can begin receiving and buffering messages
88
92
// while the handshake protocol is ongoing.
89
93
// They are currently in sleep mode.
90
- let p2p = self_ . p2p ( ) ;
94
+ let p2p = self . p2p ( ) ;
91
95
let protocols =
92
- p2p. protocol_registry ( ) . attach ( self_ . type_id ( ) , channel. clone ( ) , p2p. clone ( ) ) . await ;
96
+ p2p. protocol_registry ( ) . attach ( self . type_id ( ) , channel. clone ( ) , p2p. clone ( ) ) . await ;
93
97
94
98
// Perform the handshake protocol
95
- let protocol_version = ProtocolVersion :: new ( channel. clone ( ) , self_ . p2p ( ) . settings ( ) ) . await ;
99
+ let protocol_version = ProtocolVersion :: new ( channel. clone ( ) , self . p2p ( ) . settings ( ) ) . await ;
96
100
let handshake_task =
97
- self_ . perform_handshake_protocols ( protocol_version, channel. clone ( ) , executor. clone ( ) ) ;
101
+ self . perform_handshake_protocols ( protocol_version, channel. clone ( ) , executor. clone ( ) ) ;
98
102
99
103
// Switch on the channel
100
104
channel. start ( executor. clone ( ) ) ;
0 commit comments