@@ -1469,17 +1469,9 @@ impl Channel {
14691469 Ok ( ( ) )
14701470 }
14711471
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 ) {
14801474 let mut inbound_htlc_count: u32 = 0 ;
1481- let mut outbound_htlc_count: u32 = 0 ;
1482- let mut htlc_outbound_value_msat = 0 ;
14831475 let mut htlc_inbound_value_msat = 0 ;
14841476 for ref htlc in self . pending_inbound_htlcs . iter ( ) {
14851477 match htlc. state {
@@ -1492,6 +1484,18 @@ impl Channel {
14921484 inbound_htlc_count += 1 ;
14931485 htlc_inbound_value_msat += htlc. amount_msat ;
14941486 }
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 ;
14951499 for ref htlc in self . pending_outbound_htlcs . iter ( ) {
14961500 match htlc. state {
14971501 OutboundHTLCState :: LocalAnnounced => { if for_remote_update_check { continue ; } } ,
@@ -1504,7 +1508,7 @@ impl Channel {
15041508 htlc_outbound_value_msat += htlc. amount_msat ;
15051509 }
15061510
1507- ( inbound_htlc_count , outbound_htlc_count, htlc_outbound_value_msat, htlc_inbound_value_msat )
1511+ ( outbound_htlc_count, htlc_outbound_value_msat)
15081512 }
15091513
15101514 pub fn update_add_htlc ( & mut self , msg : & msgs:: UpdateAddHTLC , pending_forward_state : PendingHTLCStatus ) -> Result < ( ) , HandleError > {
@@ -1521,7 +1525,7 @@ impl Channel {
15211525 return Err ( HandleError { err : "Remote side tried to send less than our minimum HTLC value" , action : None } ) ;
15221526 }
15231527
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 ( ) ;
15251529 if inbound_htlc_count + 1 > OUR_MAX_HTLCS as u32 {
15261530 return Err ( HandleError { err : "Remote tried to push more than our max accepted HTLCs" , action : None } ) ;
15271531 }
@@ -2800,7 +2804,7 @@ impl Channel {
28002804 return Err ( HandleError { err : "Cannot send an HTLC while disconnected" , action : Some ( ErrorAction :: IgnoreError ) } ) ;
28012805 }
28022806
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 ) ;
28042808 if outbound_htlc_count + 1 > self . their_max_accepted_htlcs as u32 {
28052809 return Err ( HandleError { err : "Cannot push more than their max accepted HTLCs" , action : None } ) ;
28062810 }
0 commit comments