@@ -1476,17 +1476,9 @@ impl Channel {
1476
1476
Ok ( ( ) )
1477
1477
}
1478
1478
1479
- /// Returns (inbound_htlc_count, outbound_htlc_count, htlc_outbound_value_msat, htlc_inbound_value_msat)
1480
- /// If its for a remote update check, we need to be more lax about checking against messages we
1481
- /// sent but they may not have received/processed before they sent this message. Further, for
1482
- /// our own sends, we're more conservative and even consider things they've removed against
1483
- /// totals, though there is little reason to outside of further avoiding any race condition
1484
- /// issues.
1485
- fn get_pending_htlc_stats ( & self , for_remote_update_check : bool ) -> ( u32 , u32 , u64 , u64 ) {
1486
- //TODO: Can probably split this into inbound/outbound
1479
+ /// Returns (inbound_htlc_count, htlc_inbound_value_msat)
1480
+ fn get_inbound_pending_htlc_stats ( & self ) -> ( u32 , u64 ) {
1487
1481
let mut inbound_htlc_count: u32 = 0 ;
1488
- let mut outbound_htlc_count: u32 = 0 ;
1489
- let mut htlc_outbound_value_msat = 0 ;
1490
1482
let mut htlc_inbound_value_msat = 0 ;
1491
1483
for ref htlc in self . pending_inbound_htlcs . iter ( ) {
1492
1484
match htlc. state {
@@ -1499,6 +1491,18 @@ impl Channel {
1499
1491
inbound_htlc_count += 1 ;
1500
1492
htlc_inbound_value_msat += htlc. amount_msat ;
1501
1493
}
1494
+ ( inbound_htlc_count, htlc_inbound_value_msat)
1495
+ }
1496
+
1497
+ /// Returns (outbound_htlc_count, htlc_outbound_value_msat)
1498
+ /// If its for a remote update check, we need to be more lax about checking against messages we
1499
+ /// sent but they may not have received/processed before they sent this message. Further, for
1500
+ /// our own sends, we're more conservative and even consider things they've removed against
1501
+ /// totals, though there is little reason to outside of further avoiding any race condition
1502
+ /// issues.
1503
+ fn get_outbound_pending_htlc_stats ( & self , for_remote_update_check : bool ) -> ( u32 , u64 ) {
1504
+ let mut outbound_htlc_count: u32 = 0 ;
1505
+ let mut htlc_outbound_value_msat = 0 ;
1502
1506
for ref htlc in self . pending_outbound_htlcs . iter ( ) {
1503
1507
match htlc. state {
1504
1508
OutboundHTLCState :: LocalAnnounced => { if for_remote_update_check { continue ; } } ,
@@ -1511,7 +1515,7 @@ impl Channel {
1511
1515
htlc_outbound_value_msat += htlc. amount_msat ;
1512
1516
}
1513
1517
1514
- ( inbound_htlc_count , outbound_htlc_count, htlc_outbound_value_msat, htlc_inbound_value_msat )
1518
+ ( outbound_htlc_count, htlc_outbound_value_msat)
1515
1519
}
1516
1520
1517
1521
pub fn update_add_htlc ( & mut self , msg : & msgs:: UpdateAddHTLC , pending_forward_state : PendingHTLCStatus ) -> Result < ( ) , HandleError > {
@@ -1528,7 +1532,7 @@ impl Channel {
1528
1532
return Err ( HandleError { err : "Remote side tried to send less than our minimum HTLC value" , action : None } ) ;
1529
1533
}
1530
1534
1531
- let ( inbound_htlc_count, _ , _ , htlc_inbound_value_msat) = self . get_pending_htlc_stats ( true ) ;
1535
+ let ( inbound_htlc_count, htlc_inbound_value_msat) = self . get_inbound_pending_htlc_stats ( ) ;
1532
1536
if inbound_htlc_count + 1 > OUR_MAX_HTLCS as u32 {
1533
1537
return Err ( HandleError { err : "Remote tried to push more than our max accepted HTLCs" , action : None } ) ;
1534
1538
}
@@ -2803,7 +2807,7 @@ impl Channel {
2803
2807
return Err ( HandleError { err : "Cannot send an HTLC while disconnected" , action : Some ( ErrorAction :: IgnoreError ) } ) ;
2804
2808
}
2805
2809
2806
- let ( _ , outbound_htlc_count, htlc_outbound_value_msat, _ ) = self . get_pending_htlc_stats ( false ) ;
2810
+ let ( outbound_htlc_count, htlc_outbound_value_msat) = self . get_outbound_pending_htlc_stats ( false ) ;
2807
2811
if outbound_htlc_count + 1 > self . their_max_accepted_htlcs as u32 {
2808
2812
return Err ( HandleError { err : "Cannot push more than their max accepted HTLCs" , action : None } ) ;
2809
2813
}
0 commit comments