@@ -129,6 +129,9 @@ impl PeerState {
129
129
}
130
130
131
131
fn process_peer_data ( & mut self , data : & [ u8 ] , mutable_response_buffer : & mut LinkedList < Vec < u8 > > ) -> PeerDataProcessingDecision {
132
+ let mut conduit_option = None ;
133
+ let mut decision_option = None ;
134
+
132
135
match self {
133
136
& mut PeerState :: Authenticating ( ref mut handshake) => {
134
137
let ( next_act, conduit) = match handshake. process_act ( data) {
@@ -145,8 +148,8 @@ impl PeerState {
145
148
146
149
let remote_pubkey_option = handshake. get_remote_pubkey ( ) ;
147
150
if let Some ( conduit) = conduit {
148
- * self = PeerState :: Connected ( conduit) ;
149
- return PeerDataProcessingDecision :: CompleteHandshake ( requires_response, remote_pubkey_option) ;
151
+ conduit_option = Some ( conduit) ;
152
+ decision_option = Some ( PeerDataProcessingDecision :: CompleteHandshake ( requires_response, remote_pubkey_option) ) ;
150
153
}
151
154
}
152
155
@@ -155,6 +158,11 @@ impl PeerState {
155
158
}
156
159
} ;
157
160
161
+ if let ( Some ( conduit) , Some ( decision) ) = ( conduit_option, decision_option) {
162
+ * self = PeerState :: Connected ( conduit) ;
163
+ return decision;
164
+ }
165
+
158
166
PeerDataProcessingDecision :: Continue
159
167
}
160
168
}
@@ -169,8 +177,6 @@ struct Peer {
169
177
pending_outbound_buffer_first_msg_offset : usize ,
170
178
awaiting_write_event : bool ,
171
179
172
- pending_read_buffer : Vec < u8 > ,
173
-
174
180
sync_status : InitSyncTracker ,
175
181
176
182
awaiting_pong : bool ,
@@ -338,8 +344,6 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
338
344
pending_outbound_buffer_first_msg_offset : 0 ,
339
345
awaiting_write_event : false ,
340
346
341
- pending_read_buffer : Vec :: new ( ) ,
342
-
343
347
sync_status : InitSyncTracker :: NoSyncRequested ,
344
348
345
349
awaiting_pong : false ,
@@ -372,8 +376,6 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
372
376
pending_outbound_buffer_first_msg_offset : 0 ,
373
377
awaiting_write_event : false ,
374
378
375
- pending_read_buffer : Vec :: new ( ) ,
376
-
377
379
sync_status : InitSyncTracker :: NoSyncRequested ,
378
380
379
381
awaiting_pong : false ,
@@ -516,7 +518,6 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
516
518
Some ( peer) => {
517
519
518
520
let mut send_init_message = false ;
519
- let mut conduit_option = None ;
520
521
521
522
let data_processing_decision = peer. encryptor . process_peer_data ( data, & mut peer. pending_outbound_buffer ) ;
522
523
match data_processing_decision {
@@ -543,19 +544,11 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
543
544
entry. insert ( peer_descriptor. clone ( ) )
544
545
}
545
546
} ;
546
-
547
- if let & mut PeerState :: Connected ( ref mut conduit) = & mut peer. encryptor {
548
- conduit_option = Some ( conduit) ;
549
- }
550
- }
551
- PeerDataProcessingDecision :: Continue => {
552
- if let & mut PeerState :: Connected ( ref mut conduit) = & mut peer. encryptor {
553
- conduit_option = Some ( conduit) ;
554
- }
555
547
}
548
+ _ => { }
556
549
} ;
557
550
558
- if let Some ( conduit) = conduit_option {
551
+ if let & mut PeerState :: Connected ( ref mut conduit) = & mut peer . encryptor {
559
552
560
553
let encryptor = & mut conduit. encryptor ;
561
554
let decryptor = & mut conduit. decryptor ;
0 commit comments