File tree Expand file tree Collapse file tree 1 file changed +20
-23
lines changed Expand file tree Collapse file tree 1 file changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -294,29 +294,26 @@ impl ChannelMonitor {
294
294
}
295
295
}
296
296
297
- let mut waste_hash_state : Vec < [ u8 ; 32 ] > = Vec :: new ( ) ;
298
- {
299
- let local_signed_commitment_tx = & self . current_local_signed_commitment_tx ;
300
- let remote_hash_commitment_number = & self . remote_hash_commitment_number ;
301
- let min_idx = self . get_min_seen_secret ( ) ;
302
- self . payment_preimages . retain ( |& k, _| {
303
- for & ( ref htlc, _s1, _s2) in & local_signed_commitment_tx. as_ref ( ) . expect ( "Channel needs at least an initial commitment tx !" ) . htlc_outputs {
304
- if k == htlc. payment_hash {
305
- return true
306
- }
307
- }
308
- if let Some ( cn) = remote_hash_commitment_number. get ( & k) {
309
- if * cn < min_idx {
310
- return true
311
- }
312
- }
313
- waste_hash_state. push ( k) ;
314
- false
315
- } ) ;
316
- }
317
- for h in waste_hash_state {
318
- self . remote_hash_commitment_number . remove ( & h) ;
319
- }
297
+ let local_signed_commitment_tx = & self . current_local_signed_commitment_tx ;
298
+ let min_idx = self . get_min_seen_secret ( ) ;
299
+ let remote_hash_commitment_number = & mut self . remote_hash_commitment_number ;
300
+ self . payment_preimages . retain ( |& k, _| {
301
+ for & ( ref htlc, _s1, _s2) in & local_signed_commitment_tx. as_ref ( ) . expect ( "Channel needs at least an initial commitment tx !" ) . htlc_outputs {
302
+ if k == htlc. payment_hash {
303
+ return true
304
+ }
305
+ }
306
+ let contains = if let Some ( cn) = remote_hash_commitment_number. get ( & k) {
307
+ if * cn < min_idx {
308
+ return true
309
+ }
310
+ true
311
+ } else { false } ;
312
+ if contains {
313
+ remote_hash_commitment_number. remove ( & k) ;
314
+ }
315
+ false
316
+ } ) ;
320
317
321
318
Ok ( ( ) )
322
319
}
You can’t perform that action at this time.
0 commit comments