@@ -170,22 +170,33 @@ impl InFlightHtlcs {
170
170
pub fn new ( ) -> Self { InFlightHtlcs ( HashMap :: new ( ) ) }
171
171
172
172
/// Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`.
173
- pub fn process_path ( & mut self , path : & [ RouteHop ] , payer_node_id : PublicKey ) {
174
- if path. is_empty ( ) { return } ;
173
+ pub fn process_path ( & mut self , path : & Path , payer_node_id : PublicKey ) {
174
+ if path. len ( ) == 0 { return } ;
175
+
176
+ let mut cumulative_msat = 0 ;
177
+ if let Some ( tail) = & path. blinded_tail {
178
+ cumulative_msat += tail. final_value_msat + tail. fee_msat ;
179
+ self . 0
180
+ . entry ( ( tail. intro_node_scid ,
181
+ NodeId :: from_pubkey ( & path. hops . last ( ) . map_or ( payer_node_id, |hop| hop. pubkey ) ) <
182
+ NodeId :: from_pubkey ( & tail. path . introduction_node_id ) ) )
183
+ . and_modify ( |used_liquidity_msat| * used_liquidity_msat += cumulative_msat)
184
+ . or_insert ( cumulative_msat) ;
185
+ }
186
+
175
187
// total_inflight_map needs to be direction-sensitive when keeping track of the HTLC value
176
188
// that is held up. However, the `hops` array, which is a path returned by `find_route` in
177
189
// the router excludes the payer node. In the following lines, the payer's information is
178
190
// hardcoded with an inflight value of 0 so that we can correctly represent the first hop
179
191
// in our sliding window of two.
180
- let reversed_hops_with_payer = path. iter ( ) . rev ( ) . skip ( 1 )
192
+ let reversed_hops_with_payer = path. hops . iter ( ) . rev ( ) . skip ( 1 )
181
193
. map ( |hop| hop. pubkey )
182
194
. chain ( core:: iter:: once ( payer_node_id) ) ;
183
- let mut cumulative_msat = 0 ;
184
195
185
196
// Taking the reversed vector from above, we zip it with just the reversed hops list to
186
197
// work "backwards" of the given path, since the last hop's `fee_msat` actually represents
187
198
// the total amount sent.
188
- for ( next_hop, prev_hop) in path. iter ( ) . rev ( ) . zip ( reversed_hops_with_payer) {
199
+ for ( next_hop, prev_hop) in path. hops . iter ( ) . rev ( ) . zip ( reversed_hops_with_payer) {
189
200
cumulative_msat += next_hop. fee_msat ;
190
201
self . 0
191
202
. entry ( ( next_hop. short_channel_id , NodeId :: from_pubkey ( & prev_hop) < NodeId :: from_pubkey ( & next_hop. pubkey ) ) )
0 commit comments