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