@@ -1471,44 +1471,21 @@ impl Channel {
1471
1471
1472
1472
/// Returns (inbound_htlc_count, htlc_inbound_value_msat)
1473
1473
fn get_inbound_pending_htlc_stats ( & self ) -> ( u32 , u64 ) {
1474
- let mut inbound_htlc_count: u32 = 0 ;
1475
1474
let mut htlc_inbound_value_msat = 0 ;
1476
1475
for ref htlc in self . pending_inbound_htlcs . iter ( ) {
1477
- match htlc. state {
1478
- InboundHTLCState :: RemoteAnnounced => { } ,
1479
- InboundHTLCState :: AwaitingRemoteRevokeToAnnounce => { } ,
1480
- InboundHTLCState :: AwaitingAnnouncedRemoteRevoke => { } ,
1481
- InboundHTLCState :: Committed => { } ,
1482
- InboundHTLCState :: LocalRemoved => { } ,
1483
- }
1484
- inbound_htlc_count += 1 ;
1485
1476
htlc_inbound_value_msat += htlc. amount_msat ;
1486
1477
}
1487
- ( inbound_htlc_count , htlc_inbound_value_msat)
1478
+ ( self . pending_inbound_htlcs . len ( ) as u32 , htlc_inbound_value_msat)
1488
1479
}
1489
1480
1490
1481
/// Returns (outbound_htlc_count, htlc_outbound_value_msat)
1491
- /// If its for a remote update check, we need to be more lax about checking against messages we
1492
- /// sent but they may not have received/processed before they sent this message. Further, for
1493
- /// our own sends, we're more conservative and even consider things they've removed against
1494
- /// totals, though there is little reason to outside of further avoiding any race condition
1495
- /// issues.
1496
- fn get_outbound_pending_htlc_stats ( & self , for_remote_update_check : bool ) -> ( u32 , u64 ) {
1497
- let mut outbound_htlc_count: u32 = 0 ;
1482
+ fn get_outbound_pending_htlc_stats ( & self ) -> ( u32 , u64 ) {
1498
1483
let mut htlc_outbound_value_msat = 0 ;
1499
1484
for ref htlc in self . pending_outbound_htlcs . iter ( ) {
1500
- match htlc. state {
1501
- OutboundHTLCState :: LocalAnnounced => { if for_remote_update_check { continue ; } } ,
1502
- OutboundHTLCState :: Committed => { } ,
1503
- OutboundHTLCState :: RemoteRemoved => { if for_remote_update_check { continue ; } } ,
1504
- OutboundHTLCState :: AwaitingRemoteRevokeToRemove => { if for_remote_update_check { continue ; } } ,
1505
- OutboundHTLCState :: AwaitingRemovedRemoteRevoke => { if for_remote_update_check { continue ; } } ,
1506
- }
1507
- outbound_htlc_count += 1 ;
1508
1485
htlc_outbound_value_msat += htlc. amount_msat ;
1509
1486
}
1510
1487
1511
- ( outbound_htlc_count , htlc_outbound_value_msat)
1488
+ ( self . pending_outbound_htlcs . len ( ) as u32 , htlc_outbound_value_msat)
1512
1489
}
1513
1490
1514
1491
pub fn update_add_htlc ( & mut self , msg : & msgs:: UpdateAddHTLC , pending_forward_state : PendingHTLCStatus ) -> Result < ( ) , HandleError > {
@@ -2804,7 +2781,7 @@ impl Channel {
2804
2781
return Err ( HandleError { err : "Cannot send an HTLC while disconnected" , action : Some ( ErrorAction :: IgnoreError ) } ) ;
2805
2782
}
2806
2783
2807
- let ( outbound_htlc_count, htlc_outbound_value_msat) = self . get_outbound_pending_htlc_stats ( false ) ;
2784
+ let ( outbound_htlc_count, htlc_outbound_value_msat) = self . get_outbound_pending_htlc_stats ( ) ;
2808
2785
if outbound_htlc_count + 1 > self . their_max_accepted_htlcs as u32 {
2809
2786
return Err ( HandleError { err : "Cannot push more than their max accepted HTLCs" , action : None } ) ;
2810
2787
}
0 commit comments