@@ -577,13 +577,13 @@ pub type SimpleRefChannelManager<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, M, T, F, L> = C
577
577
// | |
578
578
// | |__`pending_intercepted_htlcs`
579
579
// |
580
- // |__`pending_inbound_payments `
580
+ // |__`per_peer_state `
581
581
// | |
582
- // | |__`claimable_payments `
583
- // | |
584
- // | |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds
582
+ // | |__`pending_inbound_payments `
583
+ // | |
584
+ // | |__`claimable_payments`
585
585
// | |
586
- // | |__`per_peer_state`
586
+ // | |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds
587
587
// | |
588
588
// | |__`peer_state`
589
589
// | |
@@ -3570,9 +3570,12 @@ where
3570
3570
// Ensure that no peer state channel storage lock is not held when calling this
3571
3571
// function.
3572
3572
// This ensures that future code doesn't introduce a lock_order requirement for
3573
- // `forward_htlcs` to be locked after the `per_peer_state` locks, which calling this
3574
- // function with the `per_peer_state` aquired would.
3575
- assert ! ( self . per_peer_state. try_write( ) . is_ok( ) ) ;
3573
+ // `forward_htlcs` to be locked after the `per_peer_state` peer locks, which calling
3574
+ // this function with any `per_peer_state` peer lock aquired would.
3575
+ let per_peer_state = self . per_peer_state . read ( ) . unwrap ( ) ;
3576
+ for ( _, peer) in per_peer_state. iter ( ) {
3577
+ assert ! ( peer. try_lock( ) . is_ok( ) ) ;
3578
+ }
3576
3579
}
3577
3580
3578
3581
//TODO: There is a timing attack here where if a node fails an HTLC back to us they can
@@ -6739,6 +6742,8 @@ where
6739
6742
}
6740
6743
}
6741
6744
6745
+ let per_peer_state = self . per_peer_state . write ( ) . unwrap ( ) ;
6746
+
6742
6747
let pending_inbound_payments = self . pending_inbound_payments . lock ( ) . unwrap ( ) ;
6743
6748
let claimable_payments = self . claimable_payments . lock ( ) . unwrap ( ) ;
6744
6749
let pending_outbound_payments = self . pending_outbound_payments . pending_outbound_payments . lock ( ) . unwrap ( ) ;
@@ -6754,7 +6759,6 @@ where
6754
6759
htlc_purposes. push ( purpose) ;
6755
6760
}
6756
6761
6757
- let per_peer_state = self . per_peer_state . write ( ) . unwrap ( ) ;
6758
6762
( per_peer_state. len ( ) as u64 ) . write ( writer) ?;
6759
6763
for ( peer_pubkey, peer_state_mutex) in per_peer_state. iter ( ) {
6760
6764
peer_pubkey. write ( writer) ?;
0 commit comments