@@ -241,7 +241,7 @@ where
241
241
for PhantomRouteHints { channels, phantom_scid, real_node_pubkey } in phantom_route_hints {
242
242
log_trace ! ( logger, "Generating phantom route hints for node {}" ,
243
243
log_pubkey!( real_node_pubkey) ) ;
244
- let mut route_hints = sort_and_filter_channels ( channels, amt_msat, & logger) ;
244
+ let mut route_hints: Vec < RouteHint > = sort_and_filter_channels ( channels, amt_msat, & logger) . collect ( ) ;
245
245
246
246
// If we have any public channel, the route hints from `sort_and_filter_channels` will be
247
247
// empty. In that case we create a RouteHint on which we will push a single hop with the
@@ -585,8 +585,13 @@ fn _create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_has
585
585
/// * Sorted by lowest inbound capacity if an online channel with the minimum amount requested exists,
586
586
/// otherwise sort by highest inbound capacity to give the payment the best chance of succeeding.
587
587
fn sort_and_filter_channels < L : Deref > (
588
- channels : Vec < ChannelDetails > , min_inbound_capacity_msat : Option < u64 > , logger : & L
589
- ) -> Vec < RouteHint > where L :: Target : Logger {
588
+ channels : Vec < ChannelDetails > ,
589
+ min_inbound_capacity_msat : Option < u64 > ,
590
+ logger : & L ,
591
+ ) -> Box < dyn Iterator < Item = RouteHint > >
592
+ where
593
+ L :: Target : Logger ,
594
+ {
590
595
let mut filtered_channels: HashMap < PublicKey , ChannelDetails > = HashMap :: new ( ) ;
591
596
let min_inbound_capacity = min_inbound_capacity_msat. unwrap_or ( 0 ) ;
592
597
let mut min_capacity_channel_exists = false ;
@@ -612,7 +617,7 @@ fn sort_and_filter_channels<L: Deref>(
612
617
// look at the public channels instead.
613
618
log_trace ! ( logger, "Not including channels in invoice route hints on account of public channel {}" ,
614
619
log_bytes!( channel. channel_id) ) ;
615
- return vec ! [ ]
620
+ return Box :: new ( vec ! [ ] . into_iter ( ) ) ;
616
621
}
617
622
}
618
623
@@ -672,7 +677,7 @@ fn sort_and_filter_channels<L: Deref>(
672
677
}
673
678
}
674
679
675
- let route_hint_from_channel = | channel : ChannelDetails | {
680
+ fn route_hint_from_channel ( channel : ChannelDetails ) -> RouteHint {
676
681
let forwarding_info = channel. counterparty . forwarding_info . as_ref ( ) . unwrap ( ) ;
677
682
RouteHint ( vec ! [ RouteHintHop {
678
683
src_node_id: channel. counterparty. node_id,
@@ -734,7 +739,8 @@ fn sort_and_filter_channels<L: Deref>(
734
739
} else {
735
740
b. inbound_capacity_msat . cmp ( & a. inbound_capacity_msat )
736
741
} } ) ;
737
- eligible_channels. into_iter ( ) . take ( 3 ) . map ( route_hint_from_channel) . collect :: < Vec < RouteHint > > ( )
742
+
743
+ Box :: new ( eligible_channels. into_iter ( ) . take ( 3 ) . map ( route_hint_from_channel) )
738
744
}
739
745
740
746
/// prefer_current_channel chooses a channel to use for route hints between a currently selected and candidate
0 commit comments