@@ -17,7 +17,7 @@ use bitcoin::secp256k1::PublicKey;
1717use crate :: ln:: channelmanager:: ChannelDetails ;
1818use crate :: ln:: features:: { ChannelFeatures , InvoiceFeatures , NodeFeatures } ;
1919use crate :: ln:: msgs:: { DecodeError , ErrorAction , LightningError , MAX_VALUE_MSAT } ;
20- use crate :: routing:: gossip:: { DirectedChannelInfoWithUpdate , EffectiveCapacity , ReadOnlyNetworkGraph , NetworkGraph , NodeId , RoutingFees } ;
20+ use crate :: routing:: gossip:: { DirectedChannelInfo , EffectiveCapacity , ReadOnlyNetworkGraph , NetworkGraph , NodeId , RoutingFees } ;
2121use crate :: routing:: scoring:: { ChannelUsage , Score } ;
2222use crate :: util:: ser:: { Writeable , Readable , Writer } ;
2323use crate :: util:: logger:: { Level , Logger } ;
@@ -421,7 +421,7 @@ enum CandidateRouteHop<'a> {
421421 } ,
422422 /// A hop found in the [`ReadOnlyNetworkGraph`], where the channel capacity may be unknown.
423423 PublicHop {
424- info : DirectedChannelInfoWithUpdate < ' a > ,
424+ info : DirectedChannelInfo < ' a > ,
425425 short_channel_id : u64 ,
426426 } ,
427427 /// A hop to the payee found in the payment invoice, though not necessarily a direct channel.
@@ -494,10 +494,8 @@ fn max_htlc_from_capacity(capacity: EffectiveCapacity, max_channel_saturation_po
494494 EffectiveCapacity :: Unknown => EffectiveCapacity :: Unknown . as_msat ( ) ,
495495 EffectiveCapacity :: MaximumHTLC { amount_msat } =>
496496 amount_msat. checked_shr ( saturation_shift) . unwrap_or ( 0 ) ,
497- EffectiveCapacity :: Total { capacity_msat, htlc_maximum_msat : None } =>
498- capacity_msat. checked_shr ( saturation_shift) . unwrap_or ( 0 ) ,
499- EffectiveCapacity :: Total { capacity_msat, htlc_maximum_msat : Some ( htlc_max) } =>
500- cmp:: min ( capacity_msat. checked_shr ( saturation_shift) . unwrap_or ( 0 ) , htlc_max) ,
497+ EffectiveCapacity :: Total { capacity_msat, htlc_maximum_msat } =>
498+ cmp:: min ( capacity_msat. checked_shr ( saturation_shift) . unwrap_or ( 0 ) , htlc_maximum_msat) ,
501499 }
502500}
503501
@@ -1276,13 +1274,11 @@ where L::Target: Logger {
12761274 for chan_id in $node. channels. iter( ) {
12771275 let chan = network_channels. get( chan_id) . unwrap( ) ;
12781276 if !chan. features. requires_unknown_bits( ) {
1279- let ( directed_channel, source) =
1280- chan. as_directed_to( & $node_id) . expect( "inconsistent NetworkGraph" ) ;
1281- if first_hops. is_none( ) || * source != our_node_id {
1282- if let Some ( direction) = directed_channel. direction( ) {
1283- if direction. enabled {
1277+ if let Some ( ( directed_channel, source) ) = chan. as_directed_to( & $node_id) {
1278+ if first_hops. is_none( ) || * source != our_node_id {
1279+ if directed_channel. direction( ) . enabled {
12841280 let candidate = CandidateRouteHop :: PublicHop {
1285- info: directed_channel. with_update ( ) . unwrap ( ) ,
1281+ info: directed_channel,
12861282 short_channel_id: * chan_id,
12871283 } ;
12881284 add_entry!( candidate, * source, $node_id,
@@ -1367,8 +1363,7 @@ where L::Target: Logger {
13671363 let candidate = network_channels
13681364 . get ( & hop. short_channel_id )
13691365 . and_then ( |channel| channel. as_directed_to ( & target) )
1370- . and_then ( |( channel, _) | channel. with_update ( ) )
1371- . map ( |info| CandidateRouteHop :: PublicHop {
1366+ . map ( |( info, _) | CandidateRouteHop :: PublicHop {
13721367 info,
13731368 short_channel_id : hop. short_channel_id ,
13741369 } )
@@ -1816,10 +1811,8 @@ fn add_random_cltv_offset(route: &mut Route, payment_params: &PaymentParameters,
18161811 random_channel. as_directed_from ( & cur_node_id) . map ( |( dir_info, next_id) | {
18171812 if !nodes_to_avoid. iter ( ) . any ( |x| x == next_id) {
18181813 nodes_to_avoid[ random_hop] = * next_id;
1819- dir_info. direction ( ) . map ( |channel_update_info| {
1820- random_hop_offset = channel_update_info. cltv_expiry_delta . into ( ) ;
1821- cur_hop = Some ( * next_id) ;
1822- } ) ;
1814+ random_hop_offset = dir_info. direction ( ) . cltv_expiry_delta . into ( ) ;
1815+ cur_hop = Some ( * next_id) ;
18231816 }
18241817 } ) ;
18251818 }
@@ -5214,14 +5207,12 @@ mod tests {
52145207 for channel_id in & cur_node. channels {
52155208 if let Some ( channel_info) = network_channels. get ( & channel_id) {
52165209 if let Some ( ( dir_info, next_id) ) = channel_info. as_directed_from ( & cur_node_id) {
5217- if let Some ( channel_update_info) = dir_info. direction ( ) {
5218- let next_cltv_expiry_delta = channel_update_info. cltv_expiry_delta as u32 ;
5219- if cur_path_cltv_deltas. iter ( ) . sum :: < u32 > ( )
5220- . saturating_add ( next_cltv_expiry_delta) <= observed_cltv_expiry_delta {
5221- let mut new_path_cltv_deltas = cur_path_cltv_deltas. clone ( ) ;
5222- new_path_cltv_deltas. push ( next_cltv_expiry_delta) ;
5223- candidates. push_back ( ( * next_id, new_path_cltv_deltas) ) ;
5224- }
5210+ let next_cltv_expiry_delta = dir_info. direction ( ) . cltv_expiry_delta as u32 ;
5211+ if cur_path_cltv_deltas. iter ( ) . sum :: < u32 > ( )
5212+ . saturating_add ( next_cltv_expiry_delta) <= observed_cltv_expiry_delta {
5213+ let mut new_path_cltv_deltas = cur_path_cltv_deltas. clone ( ) ;
5214+ new_path_cltv_deltas. push ( next_cltv_expiry_delta) ;
5215+ candidates. push_back ( ( * next_id, new_path_cltv_deltas) ) ;
52255216 }
52265217 }
52275218 }
@@ -5398,7 +5389,7 @@ mod tests {
53985389 let usage = ChannelUsage {
53995390 amount_msat : 0 ,
54005391 inflight_htlc_msat : 0 ,
5401- effective_capacity : EffectiveCapacity :: Total { capacity_msat : 1_024_000 , htlc_maximum_msat : Some ( 1_000 ) } ,
5392+ effective_capacity : EffectiveCapacity :: Total { capacity_msat : 1_024_000 , htlc_maximum_msat : 1_000 } ,
54025393 } ;
54035394 scorer. set_manual_penalty ( & NodeId :: from_pubkey ( & nodes[ 3 ] ) , 123 ) ;
54045395 scorer. set_manual_penalty ( & NodeId :: from_pubkey ( & nodes[ 4 ] ) , 456 ) ;
0 commit comments