@@ -17,7 +17,7 @@ use bitcoin::secp256k1::PublicKey;
17
17
use crate :: ln:: channelmanager:: ChannelDetails ;
18
18
use crate :: ln:: features:: { ChannelFeatures , InvoiceFeatures , NodeFeatures } ;
19
19
use 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 } ;
21
21
use crate :: routing:: scoring:: { ChannelUsage , Score } ;
22
22
use crate :: util:: ser:: { Writeable , Readable , Writer } ;
23
23
use crate :: util:: logger:: { Level , Logger } ;
@@ -421,7 +421,7 @@ enum CandidateRouteHop<'a> {
421
421
} ,
422
422
/// A hop found in the [`ReadOnlyNetworkGraph`], where the channel capacity may be unknown.
423
423
PublicHop {
424
- info : DirectedChannelInfoWithUpdate < ' a > ,
424
+ info : DirectedChannelInfo < ' a > ,
425
425
short_channel_id : u64 ,
426
426
} ,
427
427
/// 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
494
494
EffectiveCapacity :: Unknown => EffectiveCapacity :: Unknown . as_msat ( ) ,
495
495
EffectiveCapacity :: MaximumHTLC { amount_msat } =>
496
496
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) ,
501
499
}
502
500
}
503
501
@@ -1276,13 +1274,11 @@ where L::Target: Logger {
1276
1274
for chan_id in $node. channels. iter( ) {
1277
1275
let chan = network_channels. get( chan_id) . unwrap( ) ;
1278
1276
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 {
1284
1280
let candidate = CandidateRouteHop :: PublicHop {
1285
- info: directed_channel. with_update ( ) . unwrap ( ) ,
1281
+ info: directed_channel,
1286
1282
short_channel_id: * chan_id,
1287
1283
} ;
1288
1284
add_entry!( candidate, * source, $node_id,
@@ -1367,8 +1363,7 @@ where L::Target: Logger {
1367
1363
let candidate = network_channels
1368
1364
. get ( & hop. short_channel_id )
1369
1365
. 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 {
1372
1367
info,
1373
1368
short_channel_id : hop. short_channel_id ,
1374
1369
} )
@@ -1816,10 +1811,8 @@ fn add_random_cltv_offset(route: &mut Route, payment_params: &PaymentParameters,
1816
1811
random_channel. as_directed_from ( & cur_node_id) . map ( |( dir_info, next_id) | {
1817
1812
if !nodes_to_avoid. iter ( ) . any ( |x| x == next_id) {
1818
1813
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) ;
1823
1816
}
1824
1817
} ) ;
1825
1818
}
@@ -5214,14 +5207,12 @@ mod tests {
5214
5207
for channel_id in & cur_node. channels {
5215
5208
if let Some ( channel_info) = network_channels. get ( & channel_id) {
5216
5209
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) ) ;
5225
5216
}
5226
5217
}
5227
5218
}
@@ -5398,7 +5389,7 @@ mod tests {
5398
5389
let usage = ChannelUsage {
5399
5390
amount_msat : 0 ,
5400
5391
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 } ,
5402
5393
} ;
5403
5394
scorer. set_manual_penalty ( & NodeId :: from_pubkey ( & nodes[ 3 ] ) , 123 ) ;
5404
5395
scorer. set_manual_penalty ( & NodeId :: from_pubkey ( & nodes[ 4 ] ) , 456 ) ;
0 commit comments