@@ -1566,11 +1566,9 @@ fn add_random_cltv_offset(route: &mut Route, payment_params: &PaymentParameters,
1566
1566
1567
1567
// Remember the last three nodes of the random walk and avoid looping back on them.
1568
1568
// Init with the last three nodes from the actual path, if possible.
1569
- let last_id = NodeId :: from_pubkey ( & path. last ( ) . unwrap ( ) . pubkey ) ;
1570
- let second_last_id = NodeId :: from_pubkey ( & path. get ( path. len ( ) . saturating_sub ( 2 ) ) . unwrap ( ) . pubkey ) ;
1571
- let third_last_id = NodeId :: from_pubkey ( & path. get ( path. len ( ) . saturating_sub ( 3 ) ) . unwrap ( ) . pubkey ) ;
1572
- let mut nodes_to_avoid: [ NodeId ; 3 ] = [ third_last_id, second_last_id, last_id] ;
1573
- let mut nodes_ring_index = 0 ;
1569
+ let mut nodes_to_avoid: [ NodeId ; 3 ] = [ NodeId :: from_pubkey ( & path. last ( ) . unwrap ( ) . pubkey ) ,
1570
+ NodeId :: from_pubkey ( & path. get ( path. len ( ) . saturating_sub ( 2 ) ) . unwrap ( ) . pubkey ) ,
1571
+ NodeId :: from_pubkey ( & path. get ( path. len ( ) . saturating_sub ( 3 ) ) . unwrap ( ) . pubkey ) ] ;
1574
1572
1575
1573
// Choose the last publicly known node as the starting point for the random walk.
1576
1574
let mut cur_hop: Option < NodeId > = None ;
@@ -1589,7 +1587,7 @@ fn add_random_cltv_offset(route: &mut Route, payment_params: &PaymentParameters,
1589
1587
prng. process_in_place ( & mut random_path_bytes) ;
1590
1588
let random_walk_length = usize:: from_be_bytes ( random_path_bytes) . wrapping_rem ( 3 ) . wrapping_add ( 1 ) ;
1591
1589
1592
- for _random_hop in 0 ..random_walk_length {
1590
+ for random_hop in 0 ..random_walk_length {
1593
1591
// If we don't find a suitable offset in the public network graph, we default to
1594
1592
// MEDIAN_HOP_CLTV_EXPIRY_DELTA.
1595
1593
let mut random_hop_offset = MEDIAN_HOP_CLTV_EXPIRY_DELTA ;
@@ -1604,8 +1602,7 @@ fn add_random_cltv_offset(route: &mut Route, payment_params: &PaymentParameters,
1604
1602
. and_then ( |id| network_channels. get ( id) ) {
1605
1603
random_channel. as_directed_from ( & cur_node_id) . map ( |( dir_info, next_id) | {
1606
1604
if !nodes_to_avoid. iter ( ) . any ( |x| x == next_id) {
1607
- nodes_to_avoid[ nodes_ring_index] = * next_id;
1608
- nodes_ring_index = ( nodes_ring_index + 1 ) % 3 ;
1605
+ nodes_to_avoid[ random_hop] = * next_id;
1609
1606
dir_info. direction ( ) . map ( |channel_update_info| {
1610
1607
random_hop_offset = channel_update_info. cltv_expiry_delta . into ( ) ;
1611
1608
cur_hop = Some ( * next_id) ;
0 commit comments